ManimCommunity / ManimCommunity/manim

Unintuitive behaviour of parameter `light_source` in `ThreeDAxes`

Open
#1,945 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue:bug
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

When instantiating `ThreeDAxes` in a 3D scene, passing a new `light_source` to overwrite the default does not seem to have any effect whatsoever, neither does to directly assign to `axes.light_source` after instantiation.

Moving the light source from the default position can be achieved via `self.renderer.camera.light_source.move_to()`, as illustrated in an example in the docs. However, to enable the continuous animation of the light source shift, an updater on the `ThreeDAxes` instance is needed, linking `axes.light_source` to `self.renderer.camera.light_source`. Omitting the updater makes the change in 'lighting' abrupt.

## Expected behavior

I thought that the parameter `light_source` could be used to change the initial 'lighting' when instantiating `ThreeDAxes`. If the way to go about this is via `self.renderer.camera.light_source` that's fine, but then I would have thought that animating its movement would have been enough to change the 'lighting' smoothly, without updaters. Perhaps I haven't figured out the logic, but right now `light_source` is not a fully intuitive parameter to me.

## How to reproduce the issue

Code for reproducing the problem

```py
class ThreeDLightSourcePosition(ThreeDScene):
def construct(self):
axes = ThreeDAxes() # ThreeDAxes(light_source=3*UP) DOES NOT MOVE THE LIGHT SOURCE
axes_labels = axes.get_axis_labels()
self.set_camera_orientation(phi=60*DEGREES, theta=-30*DEGREES)

radius = 2.
sphere = ParametricSurface(
lambda u, v: np.array([
radius * np.cos(u) * np.cos(v),
radius * np.cos(u) * np.sin(v),
radius * np.sin(u)
]), v_range=[0, TAU],
u_range=[-PI / 2, PI / 2],
checkerboard_colors=[RED_D, RED_E],
resolution=(15, 32),
stroke_color=WHITE,
)
self.add(axes, axes_labels, sphere)

cam_light_source = self.renderer.camera.light_source
# WITHOUT THIS UPDATER THE CHANGE OF ILLUMINATION IS NOT CONTINUOUS
# def upd_func(mo):
# mo.light_source = np.array([cam_light_source.get_x(),
# cam_light_source.get_y(),
# cam_light_source.get_z()])
# axes.add_updater(upd_func)

cam_light_source.set_color(WHITE).move_to(3*UP) # axes.light_source = 3*UP DOES NOT MOVE THE LIGHT SOURCE
self.add(cam_light_source)
self.wait()
self.play(cam_light_source.animate.move_to(3*LEFT), run_time=2)
self.wait()
```

## Additional media files

Images/GIFs

![ThreeDLightSourcePosition_ManimCE_v0 9 0](https://user-images.githubusercontent.com/33786849/130357632-e45b1dba-17c5-458c-b331-bce0a9a6fef3.gif)

## Logs
Terminal output

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

## System specifications

System Details

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)): macOS 11.5.2 (Big Sur)
- RAM: 32GB
- Python version (`python/py/python3 --version`): 3.9.5
- Installed modules (provide output from `pip list`):
```
Package Version
---------------------- -------------------
certifi 2021.5.30
chardet 4.0.0
click 8.0.1
click-default-group 1.2.2
cloup 0.7.1
colorama 0.4.4
colour 0.1.5
commonmark 0.9.1
Cython 0.29.24
decorator 5.0.9
glcontext 2.3.4
idna 2.10
manim 0.9.0
ManimPango 0.3.0
mapbox-earcut 0.12.10
moderngl 5.6.4
moderngl-window 2.3.0
multipledispatch 0.6.0
networkx 2.5
numpy 1.20.3
Pillow 8.2.0
pip 21.1.2
pycairo 1.20.1
pydub 0.25.1
pyglet 1.5.17
Pygments 2.9.0
pyobjc-core 7.3
pyobjc-framework-Cocoa 7.3
pyrr 0.10.3
requests 2.25.1
rich 10.3.0
scipy 1.6.3
screeninfo 0.6.7
setuptools 52.0.0.post20210125
six 1.16.0
tqdm 4.61.1
urllib3 1.26.5
watchdog 2.1.2
wheel 0.36.2
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:

FFMPEG

Output of `ffmpeg -version`:

```
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.5 (clang-1205.0.22.9)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
```

## Additional comments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by tracing the ThreeDAxes light_source parameter and renderer.camera.light_source using the supplied ThreeDScene reproduction, then determine the intended relationship between them. Done means the documented or implemented behavior is consistent for initialization, reassignment, and animated movement.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.