These demos attempt to recreate many of the JoltPhysicsJS Examples
View Live Demos: https://phoenixillusion.github.io/babylonjs-jolt-physics-plugin/basic-examples/
npm install
npm run dev
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.
The app.ts
file is shared among all demo scenes. This file is a minimal BabylonJS startup routine. It performs the following:
- Create a
<canvas>
and append it to the body of the page - 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()
- a. Create a BabylonJS
- sphere_bounce - simplest demo.
- friction - influence of friction on bodies
- 2d_funnel
- 2d_funnel_instanced - using thin-mesh instances
- add_remove_bodies - adding and removing falling cubes from a live scene
- set_motion_type - set a body as being Kinematic, Dynamic, or Static
- alternative_collision_filtering - how to configure mask-based filtering
- set_layer - change the collision layer of an existing object
- falling_shapes - demo of the various supported Physics shapes
- heightfield - loading of height fields from image-maps to create terrain
- heightfield-tiling - tiling height fields into a larger field
- set_shape
- 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 - 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
- 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_factor - Setting gravity factor between 0 and 1 on a given body
- gravity_override - Customizing the impact of gravity on an individual or multiple bodies
- character_virtual_gravity - Customizing gravity on a Character Virtual
- vehicle_gravity - Customizing gravity on a Vehicle
- buoyancy - Applying a buoyancy interface to individual bodies
- buoyancy_aggregate - Using a custom grouping of buoyancy regions under a parent interface