Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/rapier-logo-notext.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 15 additions & 4 deletions examples2d/all_examples2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ mod s2d_joint_grid;
mod s2d_pyramid;
mod sensor2;
mod stress_tests;
// Tessellates an SVG with usvg, which doesn't build for wasm.
#[cfg(not(target_arch = "wasm32"))]
mod trimesh2;
mod voxels2;

Expand All @@ -67,10 +69,16 @@ type ExampleFn =
for<'a> fn(&'a mut TestbedViewer) -> Pin<Box<dyn Future<Output = anyhow::Result<()>> + 'a>>;

/// `(group, name, run-fn)` -> `(ExampleEntry, ExampleFn)`.
/// Entries accept attributes so an example can be `#[cfg]`-ed out (e.g. on wasm).
macro_rules! examples {
($($group:expr, $name:expr, $run:path);* $(;)?) => {
vec![ $( (ExampleEntry::new($group, $name), (|v| Box::pin($run(v))) as ExampleFn) ),* ]
};
($($(#[$meta:meta])* $group:ident, $name:expr, $run:path);* $(;)?) => {{
let mut entries: Vec<(ExampleEntry, ExampleFn)> = Vec::new();
$(
$(#[$meta])*
entries.push((ExampleEntry::new($group, $name), (|v| Box::pin($run(v))) as ExampleFn));
)*
entries
}};
}

#[kiss3d::main]
Expand All @@ -82,8 +90,10 @@ pub async fn main() {
const DEBUG: &str = "Debug";
const S2D: &str = "Inspired by Solver 2D";
const STRESS: &str = "Stress tests";
const B2D: &str = "Box2D benchmarks";
const B2D: &str = "Third-party benchmarks";

// Not a `vec![]`: entries can be individually `#[cfg]`-ed out.
#[allow(clippy::vec_init_then_push)]
let examples: Vec<(ExampleEntry, ExampleFn)> = examples![
// ── Collisions ──────────────────────────────────────────────────────
COLLISIONS, "Add remove", add_remove2::run;
Expand All @@ -95,6 +105,7 @@ pub async fn main() {
COLLISIONS, "Convex polygons", convex_polygons2::run;
COLLISIONS, "Heightfield", heightfield2::run;
COLLISIONS, "Polyline", polyline2::run;
#[cfg(not(target_arch = "wasm32"))]
COLLISIONS, "Trimesh", trimesh2::run;
COLLISIONS, "Voxels", voxels2::run;
COLLISIONS, "Collision groups", collision_groups2::run;
Expand Down
31 changes: 27 additions & 4 deletions examples3d/all_examples3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use std::pin::Pin;

mod utils;

// Examples gated on `not(target_arch = "wasm32")` load meshes, robot
// descriptions or scene dumps from disk, so they can't run in a browser.

mod b3d_joint_grid;
mod b3d_junkyard;
mod b3d_large_pyramid;
Expand All @@ -19,6 +22,7 @@ mod ccd3;
mod character_controller3;
mod collision_groups3;
mod compound3;
#[cfg(not(target_arch = "wasm32"))]
mod convex_decomposition3;
mod convex_polyhedron3;
mod damping3;
Expand All @@ -31,6 +35,7 @@ mod debug_boxes3;
mod debug_chain_high_mass_ratio3;
mod debug_cube_high_mass_ratio3;
mod debug_cylinder3;
#[cfg(not(target_arch = "wasm32"))]
mod debug_deserialize3;
mod debug_disabled3;
mod debug_dynamic_collider_add3;
Expand All @@ -50,6 +55,7 @@ mod debug_triangle3;
mod debug_trimesh3;
mod debug_two_cubes3;
mod domino3;
#[cfg(not(target_arch = "wasm32"))]
mod dynamic_trimesh3;
mod fountain3;
mod gyroscopic3;
Expand All @@ -59,7 +65,9 @@ mod joint_motor_position3;
mod joints3;
mod keva3;
mod locked_rotations3;
#[cfg(not(target_arch = "wasm32"))]
mod mjcf3;
#[cfg(not(target_arch = "wasm32"))]
mod mujoco_menagerie3;
mod newton_cradle3;
mod one_way_platforms3;
Expand All @@ -71,6 +79,7 @@ mod sensor3;
mod spring_joints3;
mod stress_tests;
mod trimesh3;
#[cfg(not(target_arch = "wasm32"))]
mod urdf3;
mod vehicle_controller3;
mod vehicle_joints3;
Expand All @@ -82,10 +91,16 @@ type ExampleFn =
for<'a> fn(&'a mut TestbedViewer) -> Pin<Box<dyn Future<Output = anyhow::Result<()>> + 'a>>;

/// `(group, name, run-fn)` -> `(ExampleEntry, ExampleFn)`.
/// Entries accept attributes so an example can be `#[cfg]`-ed out (e.g. on wasm).
macro_rules! examples {
($($group:expr, $name:expr, $run:path);* $(;)?) => {
vec![ $( (ExampleEntry::new($group, $name), (|v| Box::pin($run(v))) as ExampleFn) ),* ]
};
($($(#[$meta:meta])* $group:ident, $name:expr, $run:path);* $(;)?) => {{
let mut entries: Vec<(ExampleEntry, ExampleFn)> = Vec::new();
$(
$(#[$meta])*
entries.push((ExampleEntry::new($group, $name), (|v| Box::pin($run(v))) as ExampleFn));
)*
entries
}};
}

#[kiss3d::main]
Expand All @@ -97,8 +112,10 @@ pub async fn main() {
const DEBUG: &str = "Debug";
const ROBOTICS: &str = "Robotics";
const STRESS: &str = "Stress tests";
const B3D: &str = "Box3D benchmarks";
const B3D: &str = "Third-party benchmarks";

// Not a `vec![]`: entries can be individually `#[cfg]`-ed out.
#[allow(clippy::vec_init_then_push)]
let examples: Vec<(ExampleEntry, ExampleFn)> = examples![
// ── Collisions ──────────────────────────────────────────────────────
COLLISIONS, "Fountain", fountain3::run;
Expand All @@ -109,9 +126,11 @@ pub async fn main() {
COLLISIONS, "Platform", platform3::run;
COLLISIONS, "Sensor", sensor3::run;
COLLISIONS, "Compound", compound3::run;
#[cfg(not(target_arch = "wasm32"))]
COLLISIONS, "Convex decomposition", convex_decomposition3::run;
COLLISIONS, "Convex polyhedron", convex_polyhedron3::run;
COLLISIONS, "TriMesh", trimesh3::run;
#[cfg(not(target_arch = "wasm32"))]
COLLISIONS, "Dynamic trimeshes", dynamic_trimesh3::run;
COLLISIONS, "Heightfield", heightfield3::run;
COLLISIONS, "Voxels", voxels3::run;
Expand All @@ -135,8 +154,11 @@ pub async fn main() {
CONTROLS, "Vehicle controller", vehicle_controller3::run;
CONTROLS, "Vehicle joints", vehicle_joints3::run;
// ── Robotics ────────────────────────────────────────────────────────
#[cfg(not(target_arch = "wasm32"))]
ROBOTICS, "URDF", urdf3::run;
#[cfg(not(target_arch = "wasm32"))]
ROBOTICS, "MJCF", mjcf3::run;
#[cfg(not(target_arch = "wasm32"))]
ROBOTICS, "Mujoco Menagerie", mujoco_menagerie3::run;
// ── Debug ───────────────────────────────────────────────────────────
DEBUG, "Angular limits", debug_angular_limits3::run;
Expand Down Expand Up @@ -164,6 +186,7 @@ pub async fn main() {
DEBUG, "Rollback", debug_rollback3::run;
DEBUG, "Shape modification", debug_shape_modification3::run;
DEBUG, "Sleeping kinematics", debug_sleeping_kinematic3::run;
#[cfg(not(target_arch = "wasm32"))]
DEBUG, "Deserialize", debug_deserialize3::run;
DEBUG, "Multibody ang. motor pos.", debug_multibody_ang_motor_pos3::run;
// ── Stress tests ────────────────────────────────────────────────────
Expand Down
3 changes: 3 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ node_modules
.docusaurus
.cache-loader

# WASM demos, built by ./scripts/build-demos.sh
static/demos

# Misc
.DS_Store
.env.local
Expand Down
21 changes: 21 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ $ yarn start

Above command builds and starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.

### Demos

The `/demos` page embeds the `all_examples2` / `all_examples3` testbeds compiled to
WebAssembly. They are build artifacts: `static/demos` is gitignored, so it must be
generated once before `yarn build` (or `yarn start`) can serve them.

```sh
$ yarn build:demos # both demos
$ yarn build:demos all_examples2 # just one
$ yarn build:all # demos, then the website
```

Requires the `wasm32-unknown-unknown` target (`rustup target add wasm32-unknown-unknown`);
a matching `wasm-bindgen-cli` is installed under `target/` automatically if the global one
has the wrong version. `SKIP_WASM_OPT=1` skips the (slow) `wasm-opt` pass for fast
iteration, at the cost of a bigger `.wasm`. `publish.sh` runs the demo build itself.

Examples that read assets from disk (URDF/MJCF robots, `.obj` meshes, scene dumps) are
`#[cfg]`-ed out of wasm builds; see `examples2d/all_examples2.rs` and
`examples3d/all_examples3.rs`.

### Deployment

```sh
Expand Down
19 changes: 5 additions & 14 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const katex = require('rehype-katex')

const config = {
title: 'Rapier',
tagline: 'Fast 2D and 3D physics engine for the Rust programming language.',
tagline: 'High-performance 2D and 3D physics engine for the Rust programming language.',
url: 'https://rapier.rs',
baseUrl: '/',
onBrokenLinks: 'throw',
Expand All @@ -29,7 +29,7 @@ const config = {
title: 'Rapier',
logo: {
alt: 'Rapier Logo',
src: 'img/rapier_logo_color_small.svg',
src: 'img/rapier_logo_notext.png',
},
hideOnScroll: true,
items: [
Expand All @@ -40,18 +40,9 @@ const config = {
position: 'left',
},
{
to: '/demos',
label: 'Demos',
position: 'left',
items: [
{
href: 'https://rapier.rs/demos2d/index.html', // FIXME: should depend on the base url.
label: '2D Demos',
},
{
href: 'https://rapier.rs/demos3d/index.html', // FIXME: should depend on the base url.
label: '3D Demos',
}
],
},
{
to: '/community',
Expand Down Expand Up @@ -101,11 +92,11 @@ const config = {
},
{
label: 'Demos 2D',
href: 'https://rapier.rs/demos2d/index.html',
href: 'pathname:///demos#2d',
},
{
label: 'Demos 3D',
href: 'https://rapier.rs/demos3d/index.html',
href: 'pathname:///demos#3d',
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"start": "docusaurus start --host 0.0.0.0",
"preview": "PUBLISH_MODE=1 docusaurus start --host 0.0.0.0",
"build": "docusaurus build",
"build:demos": "./scripts/build-demos.sh",
"build:all": "yarn build:demos && yarn build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"serve": "docusaurus serve"
Expand Down
1 change: 1 addition & 0 deletions website/publish.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

./generate_user_guides.sh
./scripts/build-demos.sh
PUBLISH_MODE=1 yarn build
cp .htaccess build/.
rsync -av --delete-after build/ crozet@ssh.cluster003.hosting.ovh.net:/home/crozet/rapier/
Expand Down
Loading
Loading