physx-js
physx-js copied to clipboard
physx-js as ES6 module
Hello,
I am trying to use physx-js v0.7.0 as ES6 module but I have this error:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/wasm". Strict MIME type checking is enforced for module scripts per HTML spec.
Sandbox: https://plnkr.co/edit/B0kWbwZqFipXnFIX?preview
<body>
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"physx-js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/physx.release.js",
"physx-js-wasm": "https://cdn.jsdelivr.net/npm/[email protected]/dist/physx.release.wasm"
}
}
</script>
<script type="module">
import physx from "physx-js";
import physxModule from "physx-js-wasm";
const PhysX = physx({
locateFile(path)
{
if (path.endsWith(".wasm"))
{
return physxModule;
}
return path;
},
onRuntimeInitialized()
{
console.log("PhysX loaded");
}
});
</script>
</body>