3D scene occlusion
- 主要言語
- Python
- スター
- 93.8k
- フォーク
- 7.7k
- PR マージ指標
- PR 指標を取得中
説明
Is there a way to make 3D objects occlude each other?
For example, I made a surface and drawn normal vectors, but normal vectors have the same visibility regardless of whether they are behind something or not:

Here's the code I've written:
Basically I create a saddle surface and calculate normal vectors and add them to the ThreeDScene.
I tried changing the order of items, though didn't expect this would help and it didn't.
```py
class saddlepatch(ThreeDScene):
def saddle(self, x,y):
return np.array([x,y,x*y])
def vector_field_2D(self, func, boundaries):
field = np.array([func(np.array([x,y]))
for x in np.arange(boundaries["u_min"], boundaries["u_max"],.5)
for y in np.arange(boundaries["v_min"], boundaries["v_max"],.5)
])
return field
def construct(self):
TipableVMobject.position_tip = position_tip
self.move_camera(0.8*np.pi/2, -0.45*np.pi, 90)
boundaries = {
"u_min": -2, "u_max": 2,
"v_min": -2, "v_max": 2,
}
saddle_surface = ParametricSurface(self.saddle,
**boundaries, fill_opacity=0.5
)
self.add(saddle_surface)
def U(p):
x,y = p[0],p[1]
gradient_g = np.array([-y,-x,1])
return gradient_g/np.linalg.norm(gradient_g)
def U_at_p(u,p):
u = Vector(u)
UatP = u.shift(np.array([p[0], p[1], p[0]*p[1]]))
return UatP
normal_vector_field = self.vector_field_2D(lambda p: U(p)/2, boundaries)
p = self.vector_field_2D(lambda p: p, boundaries)
normal_vector_field_atP = [U_at_p(u,p) for u,p in zip(normal_vector_field,p)]
self.play(*[GrowArrow(vec) for vec in normal_vector_field_atP])
self.wait(2)
self.bring_to_front(saddle_surface)
self.begin_ambient_camera_rotation(rate=3)
self.wait(1)
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。