|
|
@@ -18,17 +18,6 @@ class Sampler extends Binding {
|
|
|
|
|
|
super( name );
|
|
|
|
|
|
- /**
|
|
|
- * This function is called when the texture is disposed.
|
|
|
- * @type {function}
|
|
|
- * @private
|
|
|
- */
|
|
|
- this._onDisposeTexture = () => {
|
|
|
-
|
|
|
- this.texture = null;
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
/**
|
|
|
* The texture the sampler is referring to.
|
|
|
*
|
|
|
@@ -71,9 +60,17 @@ class Sampler extends Binding {
|
|
|
|
|
|
if ( this._texture === value ) return;
|
|
|
|
|
|
+ const onDispose = () => {
|
|
|
+
|
|
|
+ this._texture = null;
|
|
|
+ this.generation = null;
|
|
|
+ this.version = 0;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
if ( this._texture ) {
|
|
|
|
|
|
- this._texture.removeEventListener( 'dispose', this._onDisposeTexture );
|
|
|
+ this._texture.removeEventListener( 'dispose', onDispose );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -84,7 +81,7 @@ class Sampler extends Binding {
|
|
|
|
|
|
if ( this._texture ) {
|
|
|
|
|
|
- this._texture.addEventListener( 'dispose', this._onDisposeTexture );
|
|
|
+ this._texture.addEventListener( 'dispose', onDispose );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -122,6 +119,21 @@ class Sampler extends Binding {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ clone() {
|
|
|
+
|
|
|
+ const clonedSampler = super.clone();
|
|
|
+
|
|
|
+ // fix dispose handler for cloned instances
|
|
|
+ // TODO: Find better solution, see #31747
|
|
|
+
|
|
|
+ clonedSampler._texture = null;
|
|
|
+ clonedSampler.texture = this.texture;
|
|
|
+
|
|
|
+ return clonedSampler;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
export default Sampler;
|