@ludic/ludic-box2d
v1.0.7
Published
A Box2d Ludic extension
Downloads
4
Readme
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';