3b1b / 3b1b/manim

Surface opacity issue

Offen
#1,838 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
93.8k
Forks
7.7k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

### Describe the bug
When I add two Surfaces to the scene, both with opacity less than 1, the first surface added is opaque, whilst the second is transparent. In the images below I have swapped the order in which they are added to the scene, i.e. self.add(cone1,cone2) --> self.add(cone2,cone1).

**Code**:

from manimlib import *
import numpy as np

class MyCone(Surface):
CONFIG = {
"resolution": (101, 51),
"radius": 1,
"u_range": (0, 1),
"v_range": (0, 2*PI),
}

def uv_func(self, u: float, v: float) -> np.ndarray:
return self.radius * np.array([
u * np.cos(v),
u * np.sin(v),
u
])

class MyCone2(Surface):
CONFIG = {
"resolution": (101, 51),
"radius": 1,
"u_range": (0, 1),
"v_range": (0, 2*PI),
}

def uv_func(self, u: float, v: float) -> np.ndarray:
return self.radius * np.array([
0.25+u * np.cos(v),
u * np.sin(v),
0.5-u
])

class SurfaceExample(Scene):
CONFIG = {
"camera_class": ThreeDCamera,
}

def construct(self):

cone1 = MyCone(radius=3)
cone2 = MyCone2(radius=3)

cone1.set_opacity(0.35)
cone1.set_color(RED)

cone2.set_opacity(0.35)
cone2.set_color(GREEN)

frame = self.camera.frame
frame.set_euler_angles(
theta=-30 * DEGREES,
phi=70 * DEGREES,
)

self.add(cone1,cone2)

**Wrong display or Error traceback**:

![SurfaceExample](https://user-images.githubusercontent.com/109242961/178811807-78160a27-f686-436f-bac8-2630f6c5bc76.png)
![SurfaceExample2](https://user-images.githubusercontent.com/109242961/178811811-a708da50-0497-4301-b8e7-74ebd0ad1e98.png)
k -->

### Additional context

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.