Skip to content

Conversation

@andeplane
Copy link
Owner

Summary

This PR enables the visualization of walls defined in LAMMPS using fix wall/reflect and fix wall/lj*.

Key Features:

  • Wall Extraction: New C++ methods in LAMMPSWeb to retrieve simulation dimension and wall data (type, position, style).
  • 3D Visualization: Walls are rendered as transparent inward-facing planes in the 3D view.
  • Rendering Settings: Added a "Show walls" toggle to enable/disable wall rendering dynamically.
  • Improved Geometry Utilities: Consolidated triclinic/orthogonal box detection and added comprehensive unit tests.
  • Embedded Mode Support: Wall and simulation box visibility can now be persisted in the shared/embedded URL configuration.
  • New Examples: Added 2D and 3D example simulations with wall interactions.

Technical Details:

  • Uses THREE.PlaneGeometry with quaternions for accurate 3D plane orientation.
  • Skips wall rendering for 2D simulations as the box boundary provides sufficient context.
  • Skips wall rendering for triclinic boxes (not yet supported by axis-aligned fix wall).
  • Ensures proper disposal of Three.js resources to prevent memory leaks during simulation resets.

Test Plan

  1. Open the "3D LJ particles with walls" example and verify walls are visible as light gray transparent planes.
  2. Toggle "Show walls" in settings and verify they disappear/reappear.
  3. Open the "2D LJ particles with walls" example and verify no extra wall planes are rendered.
  4. Run npm test -- src/utils/wallGeometry.test.ts src/utils/boxGeometry.test.ts to verify geometry logic.
  5. Create a shared link and verify that "Show walls" and "Show simulation box" settings are preserved.

- Add WallInfo struct and getDimension()/getWalls() methods to LAMMPSWeb
- Extract wall data from FixWall instances (EDGE and CONSTANT styles)
- Add embind bindings for wall data access from JavaScript
- Include compiled WASM and JS bindings
- Add Wall interface to types.ts
- Add dimension and walls state to simulationStatus store
- Sync walls from LAMMPS each frame in processing pipeline
- Add setDimension() and setWalls() actions
- Add createWallMesh() to create individual wall meshes
- Add createWallGroup() to create group of all walls
- Add isTriclinicBox() to detect triclinic boxes (skip wall rendering)
- Use infinitely thin planes for 3D (quaternion-based rotation)
- Use thin planes with min thickness for 2D visibility
- Walls positioned at exact boundary, facing inward
- Add wall group rendering with createWallGroup()
- Add disposeWallGroup() with proper cleanup checks
- Update disposeBoxGroup() to check scene membership before removal
- Add useEffect to sync wall rendering with state changes
- Respect showWalls setting from render settings
- Add showWalls boolean to RenderSettings interface
- Add Show walls checkbox to Settings UI
- Default value is true (walls visible by default)
- Setting persists to localStorage
- Add 2D LJ walls example (2d-lj-walls.in)
- Add 3D LJ walls example (3d-lj-walls.in) with 5 non-interacting particles
- Update examples.json with wall example entries
- Examples demonstrate transparent wall rendering in 3D and thick slabs in 2D
The box boundary already provides visual feedback for 2D systems.
Wall rendering as thin planes doesn't work well visually in 2D.
Set WALL_OPACITY to 0.1 for a more subtle glass effect.
Set WALL_OPACITY to 0.04 for an even more subtle effect.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @andeplane, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the visualization capabilities by introducing the rendering of walls defined in LAMMPS simulations. It provides the necessary backend infrastructure to extract wall data, implements a robust Three.js-based frontend rendering system for these walls, and integrates user controls and embedded URL support for seamless interaction. This allows users to better understand simulations involving confined particles or boundaries.

Highlights

  • Wall Extraction from LAMMPS: New C++ methods getDimension() and getWalls() have been added to LAMMPSWeb to retrieve simulation dimension and detailed wall data (type, position, style) from LAMMPS fix wall/reflect and fix wall/lj* instances. This data is then exposed to the JavaScript frontend.
  • 3D Wall Visualization: Walls are now rendered in the 3D view as transparent, inward-facing planes using THREE.PlaneGeometry and quaternions for accurate orientation. Rendering is skipped for 2D simulations (where the box boundary suffices) and for triclinic boxes (as axis-aligned fix wall is not yet supported for them).
  • Rendering Settings Toggle: A 'Show walls' toggle has been added to the rendering settings, allowing users to dynamically enable or disable wall visualization.
  • Improved Geometry Utilities: New utility functions isTriclinicBox and isOrthogonalBox have been introduced in boxGeometry.ts to accurately detect the type of simulation box, along with comprehensive unit tests for geometry logic.
  • Embedded Mode Persistence: The visibility settings for both the simulation box and the newly added walls can now be persisted and loaded via the shared/embedded URL configuration.
  • New Example Simulations: Two new example simulations, '2D LJ particles with walls' and '3D LJ particles with walls', have been added to demonstrate the new wall interaction and rendering capabilities.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the capability to visualize walls defined in LAMMPS simulations, supporting both fix wall/reflect and fix wall/lj*. The changes include new C++ methods in LAMMPSWeb to extract wall data, integration into the frontend to render these walls using Three.js, and new settings to control their visibility. Additionally, the PR adds new example simulations demonstrating wall interactions and improves geometry utilities with comprehensive unit tests. Resource management for Three.js objects is correctly handled to prevent memory leaks. The implementation is robust and well-tested.

@andeplane andeplane merged commit 6711045 into main Jan 21, 2026
2 checks passed
@andeplane andeplane deleted the feat/wall-rendering branch January 21, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants