Skip to content

DrA1ex/physics-js

Repository files navigation

physics-js

Yet another physics engine implementation.

image

Showcase

Snow

image

This demo project showcases the capabilities of a physics engine and built-in canvas renderer, with a focus on real-time snow physics. Additionally, a snowdrift feature has been implemented, which grows as snow particles accumulate on it, and a smoke particle system, which interacts with the environment in a realistic way.

The terrain is procedurally generated, ensuring that each scene is unique. To further enhance the visual experience, there are six different themes available for each time of day. By utilizing geoposition access, the theme can be automatically synchronized with the local sun position, creating an immersive and dynamic experience.

The demo has been designed to be used as a live desktop wallpaper or screensaver, and is compatible with popular customization tools such as Wallpaper Engine and Plash. Configuration options are available to further customize the experience to your liking.

While the demo can run without user interactions, users can click or touch the screen to play with the snowdrift and make it grow. The snow and smoke particles use an impulse-based physics solver, resulting in accurate physical interactions with the environment.

Features:

  1. Real-time snow physics.
  2. Snowdrift that grows as snow falls on it.
  3. Real-time smoke particle system with physics interactions (e.g., repelled by a snowdrift).
  4. Procedurally generated terrain.
  5. Six different themes for each time of day.
  6. Theme synchronization corresponding to the local sun position (requires geoposition access).
  7. Can be used as a desktop live wallpaper (compatible with Wallpaper Engine, Plash, etc.).
  8. Configurable options.

Themes (click to open demo)

Links

Gravity

image

This is a gravity N-Body simulation, similar to my other project available on GitHub. However, this simulation includes collision physics using a pretty accurate impulse-based physics solver.

The simulation models the interactions between multiple bodies in a gravitational field. Each body has its own position, velocity, and mass. The simulation calculates the gravitational forces between the bodies based on their relative positions and masses, and uses this information to update their velocities and positions over time. In addition to the gravitational forces, this simulation also models collisions between bodies. When two bodies collide, their velocities are adjusted based on the laws of conservation of momentum and energy. This ensures that the simulation is physically accurate and can generate realistic outcomes.

The simulation can run in real-time as it utilizes WebGL for image rendering, resulting in an image that closely resembles a lava lamp. It can be used as a screensaver or wallpaper. However, if you desire a more complex simulation, you can modify the simulation settings (the button is located in the lower-right corner) and increase the particle count or make other parameter changes.

Links:

  • 300 particles: link
  • 1000 particles: link
  • 5000 particles: link
  • Debug mode: link

Examples

Debugging

  • Optimization Tree visualization: link
  • Optimization Tree visualization 2: link
  • Optimization Tree visualization 3: link
  • Warming visualization: link