Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
for position in list(itertools.product((-bb_diag, bb_diag), (-bb_diag, bb_diag), (-bb_diag, bb_diag)))
]
ambient_light = AmbientLight(intensity=1.0)
# Set up Helpers
self.axes = Axes(bb_center=self._bb.center, length=bb_max * 1.1)
self.grid = Grid(bb_center=self._bb.center, maximum=bb_max, colorCenterLine='#aaa', colorGrid='#ddd')
# Set up scene
environment = self.axes.axes + key_lights + [ambient_light, self.grid.grid, self._camera]
scene_shp = Scene(children=[self._displayed_pickable_objects,
self._displayed_non_pickable_objects] + environment)
# Set up Controllers
self._controller = OrbitControls(controlling=self._camera, target=camera_target)
self._renderer = Renderer(camera=self._camera,
background=self._background,
background_opacity=self._background_opacity,
scene=scene_shp,
controls=[self._controller, self._picker],
width=self._size[0],
height=self._size[1],
antialias=True)
# needs to be done after setup of camera
self.grid.set_rotation((math.pi / 2.0, 0, 0, "XYZ"))
self.grid.set_position((0, 0, 0))
# Workaround: Zoom forth and back to update frame. Sometimes necessary :(
self._camera.zoom = 1.01
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))
display(VBox(display_things))
positions = list(itertools.product(*[(-orbit_radius, orbit_radius)] * 3))
key_lights = [
DirectionalLight(color='white', position=position, intensity=0.12) for position in positions
]
ambient_light = AmbientLight(intensity=1.0)
# Set up Helpers
self.axes = Axes(bb_center=self.bb.center, length=bb_max * 1.1)
self.grid = Grid(bb_center=self.bb.center, maximum=bb_max, colorCenterLine='#aaa', colorGrid='#ddd')
# Set up scene
environment = self.axes.axes + key_lights + [ambient_light, self.grid.grid, self.camera]
self.scene = Scene(children=environment + [self.pickable_objects])
# Set up Controllers
self.controller = OrbitControls(controlling=self.camera, target=camera_target, target0=camera_target)
# Update controller to instantiate camera position
self.camera.zoom = zoom
self._update()
self.picker = Picker(controlling=self.pickable_objects, event='dblclick')
self.picker.observe(self.pick)
# Create Renderer instance
self.renderer = Renderer(
scene=self.scene,
camera=self.camera,
controls=[self.controller, self.picker],
antialias=True,
width=self.width,
height=self.height)
cam = py3js.OrthographicCamera(-width/2*scale,width/2*scale, height/2*scale,
-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)