mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Add VPrism, and refactor VCube
This commit is contained in:
parent
2a7a7ac518
commit
0f8d7ed597
1 changed files with 19 additions and 16 deletions
|
@ -206,6 +206,13 @@ class Cube(SGroup):
|
||||||
return Square3D(resolution=self.square_resolution)
|
return Square3D(resolution=self.square_resolution)
|
||||||
|
|
||||||
|
|
||||||
|
class Prism(Cube):
|
||||||
|
def __init__(self, width: float = 3.0, height: float = 2.0, depth: float = 1.0, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
for dim, value in enumerate([width, height, depth]):
|
||||||
|
self.rescale_to_fit(value, dim, stretch=True)
|
||||||
|
|
||||||
|
|
||||||
class VCube(VGroup):
|
class VCube(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"fill_color": BLUE_D,
|
"fill_color": BLUE_D,
|
||||||
|
@ -213,18 +220,25 @@ class VCube(VGroup):
|
||||||
"stroke_width": 0,
|
"stroke_width": 0,
|
||||||
"gloss": 0.5,
|
"gloss": 0.5,
|
||||||
"shadow": 0.5,
|
"shadow": 0.5,
|
||||||
|
"joint_type": "round",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, side_length: int = 2, **kwargs):
|
def __init__(self, side_length: float = 2.0, **kwargs):
|
||||||
super().__init__(**kwargs)
|
|
||||||
face = Square(side_length=side_length)
|
face = Square(side_length=side_length)
|
||||||
face.get_triangulation()
|
super().__init__(*Cube.square_to_cube_faces(face), **kwargs)
|
||||||
self.add(*Cube.square_to_cube_faces(face))
|
|
||||||
self.init_colors()
|
self.init_colors()
|
||||||
|
self.set_joint_type(self.joint_type)
|
||||||
self.apply_depth_test()
|
self.apply_depth_test()
|
||||||
self.refresh_unit_normal()
|
self.refresh_unit_normal()
|
||||||
|
|
||||||
|
|
||||||
|
class VPrism(VCube):
|
||||||
|
def __init__(self, width: float = 3.0, height: float = 2.0, depth: float = 1.0, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
for dim, value in enumerate([width, height, depth]):
|
||||||
|
self.rescale_to_fit(value, dim, stretch=True)
|
||||||
|
|
||||||
|
|
||||||
class Dodecahedron(VGroup):
|
class Dodecahedron(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"fill_color": BLUE_E,
|
"fill_color": BLUE_E,
|
||||||
|
@ -272,20 +286,9 @@ class Dodecahedron(VGroup):
|
||||||
# self.add(pentagon2.copy().apply_matrix(matrix, about_point=ORIGIN))
|
# self.add(pentagon2.copy().apply_matrix(matrix, about_point=ORIGIN))
|
||||||
|
|
||||||
|
|
||||||
class Prism(Cube):
|
|
||||||
CONFIG = {
|
|
||||||
"dimensions": [3, 2, 1]
|
|
||||||
}
|
|
||||||
|
|
||||||
def init_points(self) -> None:
|
|
||||||
Cube.init_points(self)
|
|
||||||
for dim, value in enumerate(self.dimensions):
|
|
||||||
self.rescale_to_fit(value, dim, stretch=True)
|
|
||||||
|
|
||||||
|
|
||||||
class Prismify(VGroup):
|
class Prismify(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"apply_depth_test": True
|
"apply_depth_test": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, vmobject, depth=1.0, direction=IN, **kwargs):
|
def __init__(self, vmobject, depth=1.0, direction=IN, **kwargs):
|
||||||
|
|
Loading…
Add table
Reference in a new issue