首页 > 其他分享 >3D 物件

3D 物件

时间:2022-11-16 11:47:25浏览次数:42  
标签:face self 物件 length points 3D side fill

Cube

class Cube(VGroup):
    # 初始化
    def __init__(
        self,
        side_length=2,
        fill_opacity=0.75,
        fill_color=BLUE,
        stroke_width=0,
        **kwargs,
    ):
        self.side_length = side_length
        super().__init__(
            fill_color=fill_color,
            fill_opacity=fill_opacity,
            stroke_width=stroke_width,
            **kwargs,
        )

    def generate_points(self):
        for vect in IN, OUT, LEFT, RIGHT, UP, DOWN:
            face = Square(
                side_length=self.side_length,
                shade_in_3d=True,
            )
            # 摆放各个侧面
            face.flip()
            face.shift(self.side_length * OUT / 2.0)
            face.apply_matrix(z_to_vector(vect))

            self.add(face)
  init_points = generate_points
View Code

现在的问题:Cube() 的 generate_points() 为什么会自动调用呢?

标签:face,self,物件,length,points,3D,side,fill
From: https://www.cnblogs.com/daxiangcai/p/16895328.html

相关文章