-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export Bullet #17539
export Bullet #17539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
cocos/physics/bullet/instantiated.ts
Outdated
@@ -87,6 +87,7 @@ interface BtCache { | |||
|
|||
// eslint-disable-next-line import/no-mutable-exports | |||
export let bt = {} as Bullet.instance; | |||
globalThis.Bullet = bt as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Exporting Bullet to globalThis may cause namespace pollution and security issues. Consider using a more controlled export method.
Interface Check ReportThis pull request does not change any public interfaces ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
@@ -107,6 +107,7 @@ function initWASM (wasmFactory, wasmUrl: string): Promise<void> { | |||
}).then((instance: any) => { | |||
log('[bullet]:bullet wasm lib loaded.'); | |||
bt = instance as Bullet.instance; | |||
globalThis.Bullet = bt as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a more controlled export method to avoid global namespace pollution
I think we can add a comment here, or it will be removed next time because the global Bullet is used nowhere in engine it's also not a good practice to export Bullet globally |
Developers can invoke Bullet features as they need. Cocos can not wrap all features. |
Bullet is exported until this PR: #16350. I don't know why that PR removed the codes as the modification out of the range of its title.
And there is forum ticket discussion it: https://forum.cocos.org/t/topic/158556.
Greptile Summary
This PR reintroduces the global export of the Bullet physics library in the Cocos Engine, addressing a previous removal and community discussion.
globalThis.Bullet = bt as any;
incocos/physics/bullet/instantiated.ts
to make Bullet globally accessible after initialization