Lusito / box2d.ts

Full blown Box2D Ecosystem for the web, written in TypeScript
https://lusito.github.io/box2d.ts
60 stars 6 forks source link

Feature Request: Add the ESM button to jsDelivr #37

Closed 8Observer8 closed 1 year ago

8Observer8 commented 1 year ago

Please, add ESM to jsDelivr like it was made for box2d-wasm:

image

image

8Observer8 commented 1 year ago

I think it is not important. I closed it. This button is here: https://www.jsdelivr.com/package/npm/@box2d/core

image

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());
8Observer8 commented 1 year ago

You can play with my Mario example: https://8observer8.github.io/webgl10-js/mario-2d-jumps-oimophysics-webgl-js/

mario-2d-jumps-oimophysics-webgl-js