Closed 8Observer8 closed 1 year ago
I think it is not important. I closed it. This button is here: https://www.jsdelivr.com/package/npm/@box2d/core
I made this example to show how to set up @box2d/core with importmap
:
<!doctype html>
<html>
<head>
<title>Example</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<canvas id="renderCanvas"></canvas>
<!-- Since importmap is not yet supported by all browsers, it is
necessary to add the polyfill es-module-shims.min.js -->
<script async src="https://unpkg.com/es-module-shims@0.1.7/dist/es-module-shims.min.js"></script>
<script type="importmap">
{
"imports": {
"@box2d/core": "https://cdn.jsdelivr.net/npm/@box2d/core@0.10.0/+esm"
}
}
</script>
<script type="module" src="./js/main.js"></script>
</body>
</html>
main.js
import { b2World } from "@box2d/core";
const world = b2World.Create({ x: 0, y: 3 });
console.log(world.GetGravity());
You can play with my Mario example: https://8observer8.github.io/webgl10-js/mario-2d-jumps-oimophysics-webgl-js/
Please, add ESM to jsDelivr like it was made for
box2d-wasm
: