I'm making a physics extension/Help with 3D physics extension? #1891
Replies: 12 comments 19 replies
-
This is amazing! The things you do are awesome, it's great having you a part of this community! (If you have Discord, you should definitely join our community there!) |
Beta Was this translation helpful? Give feedback.
-
@CubesterYT I don't think this is how physics is supposed to work... Do you have any idea why this is happening? My guess is it has something to do with quaternion to XYZ degree Euler conversion or something related to gimbal lock or something like that but I thought I fixed that. It might be a better question for @Xeltalliv because of Simple3D integration and things video.mp4 |
Beta Was this translation helpful? Give feedback.
-
This gets even weirder when I use an infinite plane instead of a finite, thin box video.mp4 |
Beta Was this translation helpful? Give feedback.
-
I think I'm just going to re-write this whole extension from scratch again. Of course, I'll save a backup of the current version but Cannon.js just has too many limitations and the main thing holding me back from using Ammo.js was the fact that I thought it required WebAssembly but I think I figured out how to minify it and use the native JS version so I'll try that and see if it's any better |
Beta Was this translation helpful? Give feedback.
-
@CubesterYT I'm having some issues trying to get Ammo.js to work. It works like this: Of course, I know I'm supposed to put the proper ESLint comments around any minified libraries and they have to be self-contained within the extension, but something in Ammo just won't let it happen unless it's in the global scope. Any idea how I can fix this? I tried assigning it to a script tag and injecting it to the |
Beta Was this translation helpful? Give feedback.
-
@CubesterYT in what circumstances would it be acceptable to use any variables outside the TW extension IIFE? Could I use |
Beta Was this translation helpful? Give feedback.
-
It's using I tried changing the library to re-assign some of those things but I think it's everywhere and the asynchronous nature of the loading mechanism creates a bunch of issues when putting it in an IIFE... I've also tried creating custom promises and things but it doesn't seem to work because Anyone have any suggestions? |
Beta Was this translation helpful? Give feedback.
-
I suppose I should just start developing most of the functionality with Ammo.js outside the IIFE until I can figure out the asynchronous issues |
Beta Was this translation helpful? Give feedback.
-
@CubesterYT @CST1229 I've figured out the issue. So it turns out that Ammo.JS will return an undefined function error every time I try to initialize it when the minified library was pasted inside the extension IIFE. Even if I create a initialize block and execute it several minutes after the page has loaded (which should be unnecessary considering my computer is quite fast), it still returns the error, but it doesn't when the library is declared outside the IIFE, which of course is not best practices at all. At this point it's a scoping issue, not a async issue. How do you recommend I continue? I could just rename the library's variable to something like |
Beta Was this translation helpful? Give feedback.
-
I figured it out and I might have another discussion or draft PR open in a few months |
Beta Was this translation helpful? Give feedback.
-
@CST1229 and @CubesterYT: I wanted the opinion of some moderators because this is a grey area not explicitly described in the contributing guidelines. This works: Also note that the extension class and registration of the extension happens inside the |
Beta Was this translation helpful? Give feedback.
-
nice |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
video.mp4
I'm making a physics extension. It's not near done yet; this is a proof of concept, but it still kinda works.
it uses cannon.js for physics calculations but I couldn't use ammo.js because it relies on wasm and isn't native javascript...
So even though cannon is kinda old it still works.
Goals for this extension:
basically it's supposed to support everything cannon.js supports.
Don't know why the video is starting at the middle instead of the beginning
Beta Was this translation helpful? Give feedback.
All reactions