I cannot migrate a simple example from cannon to cannon-es
See original GitHub issueI have a very simple TypeScript example in cannon that just print a gravity:
import "cannon";
function main()
{
const physicsWorld = new CANNON.World();
physicsWorld.gravity.set(0, -9.82, 0);
console.log("gravity = ", physicsWorld.gravity);
}
main();
You can run it on playground: https://plnkr.co/edit/EoxKFFYZgtXnTTEX?preview
Source code on GitHub with cannon: https://github.com/8Observer8/hello-cannon-ts Source code on GitHub with cannon-es: https://github.com/8Observer8/hello-cannon-es-ts
When I try to change “cannon” to “cannon-es”, for example, this line:
import "cannon"
on this line:
import * as CANNON from "cannon-es";
I get this error: Uncaught ReferenceError: exports is not defined
and this error: Uncaught TypeError: Cannot read property 'World' of undefined
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Error migrating from cannon.js to cannon-es - Stack Overflow
I have a world with cannon.js physics working fine. When I try to migrate to cannon-es I get an error in the step()...
Read more >Bird Banding | Learn Science at Scitable - Nature
Banding was the first scientific method used to track migrating animals. ... the edge of the net with ropes and are fired simultaneously...
Read more >What is the 'salmon cannon' and how do the fish feel about it?
A video showing a cannon shooting fish over a dam went viral – but how does it work? CEO and inventor of cannon...
Read more >Migrate machines as physical servers to Azure - Microsoft Learn
In this tutorial, you learn how to: Prepare to use Azure with Migration and modernization. Check requirements for machines you want to migrate, ......
Read more >Whooshh Innovations' "Salmon Cannon" Gives Fish A Boost ...
The Whooshh Fish Transport System, also known as the "salmon cannon," gives fish a much-needed boost over dams so they can swim upstream...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, that’s how es modules work (cannon-es is an es module). Read more about it here
My advice would be to stop using Require.js, it’s an antiquated library and has been made obsolete with the introduction of es modules.
Closing since this is not related to cannon-es.
Maybe this information will help someone. Rollup works fine with TypeScript, Three.js, Cannon-es, and OrbitControls.
Debugging command:
rollup -cmw
where:-c
- create a bundle,-m
- debug mode,-w
- watch)Release commands:
rollup -c
uglifyjs public/js/bundle.js -o public/js/bundle.min.js
I edited the
rollup.config.js
script fromcannon-es
(cannon-es
is written in TypeScript): https://github.com/pmndrs/cannon-es/blob/master/rollup.config.jsrollup.config.js
src/main.ts
public/index.html