@ludic/ludic-box2d
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.7 • Public • Published

    ludic-box2d

    A Box2D Ludic extension

    To load the wasm files with webpack you need to do the following:

    Importing the files
    import Box2D from '@ludic/ludic-box2d'
    // needed for path specification
    import b2Bin from '@ludic/box2d/build/Box2D_v2.3.1_min.wasm.wasm'
     
    Box2D({locateFile: path => (path.endsWith('wasm') && b2Bin)}).then((b2)=>{
      // Module is now loaded.
      // You can now import Box2D anywhere else and
      // call things like:
      // let myVec = new Box2D.b2Vec2()
    })
    webpack.config.js
    {
      module: {
        defaultRules: [
          { type: "javascript/auto", resolve: {} },
        ],
        rules: [
          {
            test: /\.wasm$/,
            loader: 'file-loader',
            type: "javascript/auto"
          },
        ]
      }
    }
    shim-wasm.d.ts (Typescript)
    // needed to prevent tsc from complaining about module not being found
    declare module '*.wasm';

    Keywords

    none

    Install

    npm i @ludic/ludic-box2d

    DownloadsWeekly Downloads

    8

    Version

    1.0.7

    License

    none

    Unpacked Size

    69.2 kB

    Total Files

    29

    Last publish

    Collaborators

    • avatar
    • avatar