Skip to content

Latest commit

 

History

History

basic-examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Basic Examples

These demos attempt to recreate many of the JoltPhysicsJS Examples

View Live Demos: https://phoenixillusion.github.io/babylonjs-jolt-physics-plugin/basic-examples/

Running the Demos Yourself

npm install
npm run dev

Vite JS

This demo uses Vite JS [https://vitejs.dev/] for live-reload and quick development. The vite.config.ts uses a Multi-Page-Application plugin to dynamically generate the shell HTML pages, based on the Scene TS files detected in ./src/scene/.

The root page static/_index.html will auto populate, with 1 link per line linking to the individual demo Scene TS file generated template pages. The child pages static/_template.html will populate using the default exports of a given Scene TS file, launching an App class and passing in the individual camera and the scene-creation methods.

Application

The app.ts file is shared among all demo scenes. This file is a minimal BabylonJS startup routine. It performs the following:

  1. Create a <canvas> and append it to the body of the page
  2. Initialize
    • a. Create a BabylonJS Engine
    • b. Create a BabylonJS Scene
    • c. Load the JoltJS Physics Plugin
    • d. Check if the Scene TS has a custom camera, otherwise add a default Camera
    • e. Add a Light
    • f. Call the Scene TS createScene() method
    • g. Start the engine.runRenderLoop()

Individual Demo Details

Basic

Collision

Shapes

Other

  • conveyor_belt - usage of contact listeners to influence contacting bodies angular and linear velocities
  • ray_cast - raycasting from a source body, and selecting the intersected body

Constraints

  • constraints - Demonstrates multiple constraints, used as chains of cubes
  • motor - using constraint motors. Demonstrates hinge-based windmill and slider
  • springs - configuring springs on various constraints
  • path-constraint - creation of paths, and connecting bodies to paths
  • gears - advanced constraint - multiple gears or gear-and-pinion

Custom Controllers - keyboard controlled

  • character_virtual - Demonstrates a CharacterVirtual controller, allowing navigation and demonstrating contact-validation and conveyor-belt behavior
  • vehicle_motorcycle - demonstrates a simple 2-wheeled motrocycle
  • vehicle_wheeled - demonstrates a simple 4-wheeled vehicle
  • vehicle_tracked - demonstrated a 2-tracked tank-link vehicle
  • vehicle_kart - demonstrate a vehicle with tires modified to support higher speeds around corners on a track

Gravity

Buoyancy

  • buoyancy - Applying a buoyancy interface to individual bodies
  • buoyancy_aggregate - Using a custom grouping of buoyancy regions under a parent interface