File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,11 +60,12 @@ export class TextureEffect extends Effect {
6060 if ( prevTexture !== value ) {
6161
6262 uniforms . get ( "map" ) . value = value ;
63- uniforms . get ( "uvTransform" ) . value = value . matrix ;
6463 defines . delete ( "TEXTURE_PRECISION_HIGH" ) ;
6564
6665 if ( value !== null ) {
6766
67+ uniforms . get ( "uvTransform" ) . value = value . matrix ;
68+
6869 if ( value . matrixAutoUpdate ) {
6970
7071 defines . set ( "UV_TRANSFORM" , "1" ) ;
@@ -89,6 +90,12 @@ export class TextureEffect extends Effect {
8990
9091 }
9192
93+ } else {
94+
95+ uniforms . get ( "uvTransform" ) . value = null ;
96+ defines . delete ( "UV_TRANSFORM" ) ;
97+ this . setVertexShader ( null ) ;
98+
9299 }
93100
94101 }
Original file line number Diff line number Diff line change 11import test from "ava" ;
2- import { TextureEffect } from "postprocessing" ;
2+ import { Texture } from "three" ;
3+ import { EffectPass , TextureEffect } from "postprocessing" ;
34
45test ( "can be created and destroyed" , t => {
56
@@ -16,3 +17,28 @@ test("can be updated", t => {
1617 t . notThrows ( ( ) => effect . update ( ) ) ;
1718
1819} ) ;
20+
21+ test ( "can clear an existing texture" , t => {
22+
23+ const effect = new TextureEffect ( { texture : new Texture ( ) } ) ;
24+ t . notThrows ( ( ) => { effect . texture = null ; } ) ;
25+ t . is ( effect . texture , null ) ;
26+
27+ } ) ;
28+
29+ test ( "recompiles its host pass after clearing an existing texture" , t => {
30+
31+ const texture = new Texture ( ) ;
32+ texture . matrixAutoUpdate = true ;
33+
34+ const effect = new TextureEffect ( { texture } ) ;
35+ const pass = new EffectPass ( null , effect ) ;
36+ pass . initialize ( null , false , undefined ) ;
37+
38+ t . true ( pass . fullscreenMaterial . vertexShader . includes ( "UvTransform" ) ) ;
39+
40+ t . notThrows ( ( ) => { effect . texture = null ; } ) ;
41+
42+ t . false ( pass . fullscreenMaterial . vertexShader . includes ( "UvTransform" ) ) ;
43+
44+ } ) ;
You can’t perform that action at this time.
0 commit comments