Sampler: Fix dispose.#31751
Conversation
| * @type {function} | ||
| * @private | ||
| */ | ||
| this._onDisposeTexture = () => { |
There was a problem hiding this comment.
_onDisposeTexture() is cloned like all other properties. Because EventListener does not let you assign the same listener more than once, only the first dispose works. It has to be inlined in the setter of texture to make it work.
| // TODO: Find better solution, see #31747 | ||
|
|
||
| clonedSampler._texture = null; | ||
| clonedSampler.texture = this.texture; |
There was a problem hiding this comment.
An explicit call of the texture setter is required so cloned instances have proper dispose event listeners.
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
For |
Related issue: #31747 (comment)
Description
Fixes the dispose logic in the
Samplerbinding class.