How to use the pythreejs.Group function in pythreejs

To help you get started, we’ve selected a few pythreejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bernhard-42 / jupyter-cadquery / jupyter_cadquery / cad_view.py View on Github external
self.info = info
        self.timeit = timeit

        self.camera_distance_factor = 6
        self.camera_initial_zoom = 2.5

        self.features = ["mesh", "edges"]

        self.bb = None

        self.default_mesh_color = default_mesh_color or self._format_color(166, 166, 166)
        self.default_edge_color = default_edge_color or self._format_color(128, 128, 128)
        self.pick_color = self._format_color(232, 176, 36)

        self.shapes = []
        self.pickable_objects = Group()
        self.pick_last_mesh = None
        self.pick_last_mesh_color = None
        self.pick_mapping = []

        self.camera = None
        self.axes = None
        self.grid = None
        self.scene = None
        self.controller = None
        self.renderer = None

        self.savestate = None
github cihologramas / pyoptools / pyoptools / gui / ipywidgets.py View on Github external
def comp2mesh(C, P, D):
    c=py3js.Group()
    if isinstance(C, Component):
        for surf in C.surflist:
            sS, sP, sD = surf
            s=surf2mesh(sS,sP,sD)
            c.add(s)
    
    elif isinstance(C, System):
       for comp in C.complist:
            sC, sP, sD = comp
            c.add(comp2mesh(sC, sP, sD))
    #glPopMatrix()
    c.rotation=*D,"ZYX"
    c.position=tuple(P)
    return c
github cihologramas / pyoptools / pyoptools / gui / ipywidgets.py View on Github external
def sys2mesh(os):
    s=py3js.Group()
    if os is not None:
        for i in os.prop_ray:
            s.add(ray2mesh(i))
        # Draw Components
        n=0
        for comp in os.complist:    
            C, P, D = comp
            c=comp2mesh(C, P, D)
            s.add(c)
    return s
github cihologramas / pyoptools / pyoptools / gui / ipywidgets.py View on Github external
def ray2mesh(ray):
    rays=py3js.Group()

    w = ray.wavelength
    rc, gc, bc = wavelength2RGB(w)
    rc=int(255*rc)
    gc=int(255*gc)
    bc=int(255*bc)
    material = py3js.LineBasicMaterial(color = "#{:02X}{:02X}{:02X}".format(rc,gc,bc))



    rl = ray2list(ray)

    for r in rl:
        geometry = py3js.Geometry()
        geometry.vertices =  r
        line = py3js.Line( geometry, material)
github tpaviot / pythonocc-core / src / Display / WebGl / jupyter_renderer.py View on Github external
self._bb = None  # the bounding box, necessary to compute camera position

        # the default camera object
        self._camera_target = [0., 0., 0.]  # the point to look at
        self._camera_position = [0, 0., 100.]  # the camera initial position
        self._camera = None

        # a dictionnary of all the shapes belonging to the renderer
        # each element is a key 'mesh_id:shape'
        self._shapes = {}

        # we save the renderer so that is can be accessed
        self._renderer = None

        # the group of 3d and 2d objects to render
        self._displayed_pickable_objects = Group()

        # the group of other objects (grid, trihedron etc.) that can't be selected
        self._displayed_non_pickable_objects = Group()

        # event manager/selection manager
        self._picker = Picker(controlling=self._displayed_pickable_objects, event='mousedown')

        self._current_shape_selection = None
        self._current_mesh_selection = None
        self._selection_color = format_color(232, 176, 36)

        self._select_callbacks = []  # a list of all functions called after an object is selected


        def click(value):
            """ called whenever a shape  or edge is clicked