You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ahoy! I'm looking to import rapier.js (a Rust physics engine that can use JS) in both the client/server but running in to issues I think with both.
The sample code tried on client.js:
import('@dimforge/rapier2d').then(RAPIER => {
// Use the RAPIER module here.
let gravity = { x: 0.0, y: -9.81 };
let world = new RAPIER.World(gravity);
// Create the ground
let groundColliderDesc = RAPIER.ColliderDesc.cuboid(10.0, 0.1);
world.createCollider(groundColliderDesc);
// Create a dynamic rigid-body.
let rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic()
.setTranslation(0.0, 1.0);
let rigidBody = world.createRigidBody(rigidBodyDesc);
// Create a cuboid collider attached to the dynamic rigidBody.
let colliderDesc = RAPIER.ColliderDesc.cuboid(0.5, 0.5);
let collider = world.createCollider(colliderDesc, rigidBody);
// Game loop. Replace by your own game loop system.
let gameLoop = () => {
// Ste the simulation forward.
world.step();
// Get and print the rigid-body's position.
let position = rigidBody.translation();
console.log("Rigid-body position: ", position.x, position.y);
setTimeout(gameLoop, 16);
};
gameLoop();
})
The client.js failed w/:
text: 'No loader is configured for ".wasm" files: node_modules/.pnpm/@dimforge+rapier2d@0.11.2/node_modules/@dimforge/rapier2d/rapier_wasm2d_bg.wasm'
(I might be able to figure it out if I eject from the partykit client build? but I really like the simple build experience atm!)
The server.js while running pnpm run dev is able to complete the import, but within the local dev server it seems like execution is seemingly stopping on the World create JS step, but not sure if there's any way to capture a stack trace / error when a pre-built wasm just halts execution like that 🤔
The text was updated successfully, but these errors were encountered:
hrmm I think I see the problem here, browsers load wasm files differently, they're meant to be considered actual files that get loaded and parsed, but you'd like to use the same code in both places. Lemme spend some time later and show how you could possibly do this with rapier
Ahoy! I'm looking to import rapier.js (a Rust physics engine that can use JS) in both the client/server but running in to issues I think with both.
The sample code tried on client.js:
The client.js failed w/:
text: 'No loader is configured for ".wasm" files: node_modules/.pnpm/@dimforge+rapier2d@0.11.2/node_modules/@dimforge/rapier2d/rapier_wasm2d_bg.wasm'
(I might be able to figure it out if I eject from the partykit client build? but I really like the simple build experience atm!)
The server.js while running
pnpm run dev
is able to complete the import, but within the local dev server it seems like execution is seemingly stopping on the World create JS step, but not sure if there's any way to capture a stack trace / error when a pre-built wasm just halts execution like that 🤔The text was updated successfully, but these errors were encountered: