Open DennisSmolek opened 7 months ago
I wouldn't call the Raw
object we have a "global" in the same sense as the window.Jolt global in the jolt demos.
The Raw
object we currently have would maybe be better described as an exported "singleton" object.
For context - earlier the jolt build didn't use emscripten MODULARIZE, emscripten set window.Jolt. When we swapped to MODULARIZE, to avoid changing all the demos I added back an assignment to window.Jolt 😄
Assigning to window / globalThis in a demo is fine, but it's not a good idea to do this in a library.
Maybe a better name could be JoltModule
or something?
But as discussed on discord - there's other ways we could pass around the jolt emscripten module. They would require a bit of refactoring though.
Maybe a better name could be
JoltModule
or something?
I think I like this better than Raw
But as discussed on discord - there's other ways we could pass around the jolt emscripten module. They would require a bit of refactoring though.
The problem with that is it breaks all utility functions. Any function that touches Jolt would need to be passed the Jolt interface. All functions would have to become methods of a class.
So we'd init everything like PhysicsSystem.utils = new Utils(JoltWasm)
or whatever. then call utils.vec3.three(position)
Because of Suspense/Async initiation issues with Jolt @isaac-mason's original library created a global object called
Raw
and accessing it was done withRaw.module
The jolt demos don't have to do this because they wait for the
JoltInit
promise before doing anything, and by thenJolt
is correctly established on the Window as a global. So instead ofnew Raw.module.Vec3()
for example, they donew Jolt.Vec3()
Jolt
item as a global. I've not seen other libraries pull this off.If we decide to/have to keep it, should we continue to call it 'Raw.module` or would a semantic name be better?