mirror of
https://github.com/galacean/engine.git
synced 2026-06-01 00:05:56 +08:00
Support destroy physicsMaterial (#2481)
* feat: support destroy physicsMaterial
This commit is contained in:
@@ -97,9 +97,9 @@ export class PhysicsMaterial {
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Destroy the material when the material is no be used by any shape.
|
||||
*/
|
||||
_destroy() {
|
||||
destroy() {
|
||||
!this._destroyed && this._nativeMaterial.destroy();
|
||||
this._destroyed = true;
|
||||
}
|
||||
|
||||
@@ -486,4 +486,12 @@ describe("PhysicsMaterial", () => {
|
||||
engine.sceneManager.activeScene.physics._update(1);
|
||||
expect(formatValue(boxEntity2.transform.position.z)).eq(0.57139);
|
||||
});
|
||||
|
||||
it("destroy", () => {
|
||||
const physicsMaterial = new PhysicsMaterial();
|
||||
physicsMaterial.destroy();
|
||||
expect(() => {
|
||||
physicsMaterial.bounciness = 1;
|
||||
}).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user