Add ImplicitSurface class for 3D implicit surface visualization#4499
Open
jakekinchen wants to merge 9 commits intoManimCommunity:mainfrom
Open
Add ImplicitSurface class for 3D implicit surface visualization#4499jakekinchen wants to merge 9 commits intoManimCommunity:mainfrom
jakekinchen wants to merge 9 commits intoManimCommunity:mainfrom
Conversation
Introduces a new ImplicitSurface mobject that visualizes 3D surfaces defined by implicit functions f(x, y, z) = 0, similar to how ImplicitFunction handles 2D implicit curves. Features: - Uses PyMCubes library for marching cubes mesh extraction (~50-300KB) - Configurable resolution parameter for mesh density control - High vertex accuracy (mean error < 0.001 for unit sphere) - Supports both Cairo and OpenGL renderers - Includes verify_surface() method for accuracy validation New dependency: pymcubes>=0.1.0 Includes unit tests, graphical tests, and example scenes demonstrating spheres, tori, gyroids, and other implicit surfaces.
for more information, see https://pre-commit.ci
The ImplicitSurface functionality is already covered by unit tests in tests/module/mobject/test_implicit_surface.py
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
- Add proper type annotations to __init__ and method signatures - Remove unused type: ignore comments - Fix return types to match parent class signatures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new
ImplicitSurfacemobject that enables visualization of 3D surfaces defined by implicit functionsf(x, y, z) = 0, analogous to howImplicitFunctionhandles 2D implicit curves.Key Features
verify_surface()for accuracy validationNew Dependency
pymcubes>=0.1.0- Fast, lightweight marching cubes implementationExample Usage
Rendered Examples
Sphere (unit sphere with 3D axes):

Torus (major radius 2, minor radius 0.5):

Gyroid (minimal surface with salmon-to-pink gradient):

Files Changed
manim/mobject/three_d/implicit_surface.py- Main implementationmanim/mobject/opengl/opengl_implicit_surface.py- OpenGL renderer supporttests/module/mobject/test_implicit_surface.py- 10 unit teststests/test_graphical_units/test_threed.py- Graphical regression testsexample_scenes/implicit_surface_examples.py- 6 example scenespyproject.toml- Added pymcubes dependencyTest Plan
pytest tests/module/mobject/test_implicit_surface.py)ruff check)Related
ImplicitFunctionfor 2D curvesSurfaceclass for parametric surfaces