本文整理汇总了Python中pythreejs.Renderer方法的典型用法代码示例。如果您正苦于以下问题:Python pythreejs.Renderer方法的具体用法?Python pythreejs.Renderer怎么用?Python pythreejs.Renderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythreejs
的用法示例。
在下文中一共展示了pythreejs.Renderer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pythreejs [as 别名]
# 或者: from pythreejs import Renderer [as 别名]
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
示例2: Plot3D
# 需要导入模块: import pythreejs [as 别名]
# 或者: from pythreejs import Renderer [as 别名]
def Plot3D(S,size=(800,200),center=(0,0,0), rot=[(pi/3., pi/6., 0 )],scale=1):
"""Function to create 3D interactive visualization widgets in a jupyter
notebook
Args:
S: (:class:`~pyoptools.raytrace.system.System`,
:class:`~pyoptools.raytrace.component.Component` or
:class:`~pyoptools.raytrace.component.Component`) Object to plot
size: (Tuple(float,float)) Field of view in X and Y for the window
shown in the notebook.
center: (Tuple(float,float,float) Coordinate of the center of the
visualization window given in the coordinate system of the object
to plot.
rot: List of tuples. Each tuple describe an (Rx, Ry, Rz) rotation and
are applied in order to generate the first view of the window.
scale: (float) Scale factor applied to the rendered window
Returns:
pyjs renderer needed to show the image in the jupiter notebook.
"""
width,height=size
light = py3js.DirectionalLight(color='#ffffff',
intensity=.7,
position=[0, 1000,0])
alight = py3js.AmbientLight(color='#777777',)
# Set up a scene and render it:
#cam = py3js.PerspectiveCamera(position=[0, 0, 500], fov=70, children=[light], aspect=width / height)
pos = array((0, 0, 500))
for r in rot:
pos=dot(rot_z(r[2]),pos)
pos=dot(rot_y(r[1]),pos)
pos=dot(rot_x(r[0]),pos)
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)