npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thorium-sim/rapier2d-node

v0.13.2

Published

A NodeJS compatibility package for https://rapier.rs JS bindings

Downloads

4

Readme

rapier2d-node

A NodeJS compatibility package for https://rapier.rs JS bindings

Rapier doesn't ship a package currently that works in NodeJS out of the box. The goal of this repo is to publish packages for Rapier which you can just require and use on the latest version of Node.

Installing the package

For 3D, npm i -s @thorium-sim/rapier2d-node.

Usage:

import RAPIER from '@thorium-sim/rapier2d-node'

const world = new RAPIER.World({ x: 0, y: 9.81 })

No async import or await RAPIER.init() is required.

Building the packages

  1. Install Rust
  2. cargo install wasm-pack
  3. npm install
  4. npm run build

What this project does

  1. Builds with wasm-pack --target nodejs instead of --target web to produce Node-compatible WASM modules
  2. Injects missing globals into Node's global scope (no extra libs, just using Node core stuff): a. self b. atob c. performance.now
  3. Removes binding definitions for the opposite dimensionality (removes 3d APIs for the 2d library and vice versa)
  4. Copies the TS bindings files from rapier.js alongside the WASM module output
  5. Compiles the TS to create the fully bound library with the same interface as the web versions

Testing

I copied a simple test scene from https://github.com/AutomatonSystems/rapier-node to test/test.js. You can run npm test to execute the script; if you see positions logged and it completes successfully, the library has at least loaded and ran!

Attributions

This is a clone of https://github.com/a-type/rapier-node. The project seems unmaintained, but credit to a-type for his initial work on this. I will do my best to keep this project in sync with Rapier.js. If I'm behind a version, feel free to open an issue and I will get it updated.

The differences between rapier-node and @a-type/rapier-node are as follows:

  1. Update to the latest Rapier.js source 0.7.6.
  2. Refactored the build chain to be more streamlined.
  3. Fixed typescript definition generation weirdness.
  4. Added README.md to published packages.
  5. Swapped out yarn for npm.