Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/renderers/common/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ class Bindings extends DataMap {

binding.release();

} else if ( binding.isSampler ) {

binding.release();

}

}
Expand Down
22 changes: 22 additions & 0 deletions src/renderers/common/RenderObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ class RenderObject {
*/
this._monitor = null;

/**
* The object's original material when this render object is drawn with an
* override material.
*
* @type {?Material}
* @private
* @default null
*/
this._sourceMaterial = renderer._currentSourceMaterial;

/**
* An event listener which is defined by `RenderObjects`. It performs
* clean up tasks when `dispose()` on this render object.
Expand Down Expand Up @@ -328,6 +338,12 @@ class RenderObject {
this.material.addEventListener( 'dispose', this.onMaterialDispose );
this.geometry.addEventListener( 'dispose', this.onGeometryDispose );

if ( this._sourceMaterial !== null ) {

this._sourceMaterial.addEventListener( 'dispose', this.onMaterialDispose );

}

}

/**
Expand Down Expand Up @@ -923,6 +939,12 @@ class RenderObject {
this.material.removeEventListener( 'dispose', this.onMaterialDispose );
this.geometry.removeEventListener( 'dispose', this.onGeometryDispose );

if ( this._sourceMaterial !== null ) {

this._sourceMaterial.removeEventListener( 'dispose', this.onMaterialDispose );

}

this.onDispose();

}
Expand Down
16 changes: 16 additions & 0 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ class Renderer {
*/
this._compilationPromises = null;

/**
* When an override material is in use, this property points to the current
* source material during the rendering of a render object.
*
* @private
* @type {?Material}
* @default null
*/
this._currentSourceMaterial = null;

/**
* Whether the renderer should render transparent render objects or not.
*
Expand Down Expand Up @@ -3483,6 +3493,8 @@ class Renderer {
let materialPositionNode;
let materialSide;

const previousSourceMaterial = this._currentSourceMaterial;

//

object.onBeforeRender( this, scene, camera, geometry, material, group );
Expand All @@ -3491,6 +3503,8 @@ class Renderer {

if ( material.allowOverride === true && scene.overrideMaterial !== null ) {

this._currentSourceMaterial = material;

const overrideMaterial = scene.overrideMaterial;

materialOverride = true;
Expand Down Expand Up @@ -3566,6 +3580,8 @@ class Renderer {

}

this._currentSourceMaterial = previousSourceMaterial;

//

object.onAfterRender( this, scene, camera, geometry, material, group );
Expand Down
9 changes: 9 additions & 0 deletions src/renderers/common/Sampler.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ class Sampler extends Binding {

}

/**
* Releases the texture reference.
*/
release() {

this._texture = null;

}

}

export default Sampler;
1 change: 1 addition & 0 deletions src/renderers/common/Textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ class Textures extends DataMap {
if ( binding.isSampler && binding.texture === texture ) {

binding.reset();
binding.release();

}

Expand Down