diff --git a/packages/core/src/physics/PhysicsMaterial.ts b/packages/core/src/physics/PhysicsMaterial.ts index f997e7869..382e46904 100644 --- a/packages/core/src/physics/PhysicsMaterial.ts +++ b/packages/core/src/physics/PhysicsMaterial.ts @@ -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; } diff --git a/tests/src/core/physics/PhysicsMaterial.test.ts b/tests/src/core/physics/PhysicsMaterial.test.ts index ca26f85c3..43b0daa44 100644 --- a/tests/src/core/physics/PhysicsMaterial.test.ts +++ b/tests/src/core/physics/PhysicsMaterial.test.ts @@ -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(); + }); });