-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make react-native-rapier work with rapier3d layer
- Loading branch information
1 parent
5331828
commit 0e6a8e1
Showing
5 changed files
with
140 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
diff --git a/node_modules/@dimforge/rapier3d-compat/rapier_wasm3d.js b/node_modules/@dimforge/rapier3d-compat/rapier_wasm3d.js | ||
index fe98b77..3459f7a 100644 | ||
--- a/node_modules/@dimforge/rapier3d-compat/rapier_wasm3d.js | ||
+++ b/node_modules/@dimforge/rapier3d-compat/rapier_wasm3d.js | ||
@@ -1,3 +1,4 @@ | ||
+import Rapier from '@callstack/react-native-rapier' | ||
|
||
let wasm; | ||
|
||
@@ -5081,48 +5082,26 @@ function initMemory(imports, maybe_memory) { | ||
|
||
} | ||
|
||
-function finalizeInit(instance, module) { | ||
- wasm = instance.exports; | ||
- init.__wbindgen_wasm_module = module; | ||
- cachedFloat32Memory0 = new Float32Array(); | ||
- cachedFloat64Memory0 = new Float64Array(); | ||
- cachedInt32Memory0 = new Int32Array(); | ||
- cachedUint32Memory0 = new Uint32Array(); | ||
- cachedUint8Memory0 = new Uint8Array(); | ||
+function __wbg_finalize_init(instance, module) { | ||
+ wasm = module.exports; | ||
+ __wbg_init.__wbindgen_wasm_module = module; | ||
+ cachedFloat32Memory0 = null; | ||
+ cachedFloat64Memory0 = null; | ||
+ cachedInt32Memory0 = null; | ||
+ cachedUint32Memory0 = null; | ||
+ cachedUint8Memory0 = null; | ||
|
||
- | ||
- return wasm; | ||
+ return wasm; | ||
} | ||
|
||
function initSync(module) { | ||
- const imports = getImports(); | ||
- | ||
- initMemory(imports); | ||
- | ||
- if (!(module instanceof WebAssembly.Module)) { | ||
- module = new WebAssembly.Module(module); | ||
- } | ||
- | ||
- const instance = new WebAssembly.Instance(module, imports); | ||
- | ||
- return finalizeInit(instance, module); | ||
+ const mod = Rapier.create({ wbg: {} }); | ||
+ return __wbg_finalize_init({}, mod); | ||
} | ||
|
||
-async function init(input) { | ||
- if (typeof input === 'undefined') { | ||
- input = new URL('rapier_wasm3d_bg.wasm', "<deleted>"); | ||
- } | ||
- const imports = getImports(); | ||
- | ||
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { | ||
- input = fetch(input); | ||
- } | ||
- | ||
- initMemory(imports); | ||
- | ||
- const { instance, module } = await load(await input, imports); | ||
- | ||
- return finalizeInit(instance, module); | ||
+async function __wbg_init(input) { | ||
+ const mod = Rapier.create({ wbg: {} }); | ||
+ return __wbg_finalize_init({}, mod); | ||
} | ||
|
||
export { initSync } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters