How does react use the 'cannon.js' physics engine?

In the react project, I installed cannon. js – NPM install Cannon by ES5
But how do I seem to have failed in the project?

Pinging @RaananW

I need a bit more information about your build environment to be able to help. If I see correctly, you are using Babylon’s UMD version (and not the es6). I assume cannon was installed using npm?

How does your packer setup look like? are you using webpack? something else?

Have you tried setting CANNON on the globalThis variable? (in your case - window):



If you set window.CANNON = CANNON then you need to change your import * to:

import * as CANNON from ‘cannon’;

1 Like

Thank you very much .I installed with the es5 version, and now my solution is to introduce ‘cannon’ directly into the script tag in ‘index.html’. But I don’t know if there’s a downside to that

it is answer,very good!

Thank you very much for your method, which I have successfully used