@@ -16,30 +16,40 @@ function setTextureProperties (texture, data) {
1616 var offset = data . offset || { x : 0 , y : 0 } ;
1717 var repeat = data . repeat || { x : 1 , y : 1 } ;
1818 var npot = data . npot || false ;
19- var anisotropy = data . anisotropy || 0 ;
19+ var anisotropy = data . anisotropy || THREE . Texture . DEFAULT_ANISOTROPY ;
20+ var wrapS = texture . wrapS ;
21+ var wrapT = texture . wrapT ;
22+ var magFilter = texture . magFilter ;
23+ var minFilter = texture . minFilter ;
24+
2025 // To support NPOT textures, wrap must be ClampToEdge (not Repeat),
2126 // and filters must not use mipmaps (i.e. Nearest or Linear).
2227 if ( npot ) {
23- texture . wrapS = THREE . ClampToEdgeWrapping ;
24- texture . wrapT = THREE . ClampToEdgeWrapping ;
25- texture . magFilter = THREE . LinearFilter ;
26- texture . minFilter = THREE . LinearFilter ;
28+ wrapS = THREE . ClampToEdgeWrapping ;
29+ wrapT = THREE . ClampToEdgeWrapping ;
30+ magFilter = THREE . LinearFilter ;
31+ minFilter = THREE . LinearFilter ;
2732 }
2833
29- // Don't bother setting repeat if it is 1/1. Power-of-two is required to repeat.
34+ // Set wrap mode to repeat only if repeat isn't 1/1. Power-of-two is required to repeat.
3035 if ( repeat . x !== 1 || repeat . y !== 1 ) {
31- texture . wrapS = THREE . RepeatWrapping ;
32- texture . wrapT = THREE . RepeatWrapping ;
33- texture . repeat . set ( repeat . x , repeat . y ) ;
34- }
35- // Don't bother setting offset if it is 0/0.
36- if ( offset . x !== 0 || offset . y !== 0 ) {
37- texture . offset . set ( offset . x , offset . y ) ;
36+ wrapS = THREE . RepeatWrapping ;
37+ wrapT = THREE . RepeatWrapping ;
3838 }
3939
40- // Only set anisotropy if it isn't 0, which indicates that the default value should be used.
41- if ( anisotropy !== 0 ) {
40+ // Apply texture properties
41+ texture . offset . set ( offset . x , offset . y ) ;
42+ texture . repeat . set ( repeat . x , repeat . y ) ;
43+
44+ if ( texture . wrapS !== wrapS || texture . wrapT !== wrapT ||
45+ texture . magFilter !== magFilter || texture . minFilter !== minFilter ||
46+ texture . anisotropy !== anisotropy ) {
47+ texture . wrapS = wrapS ;
48+ texture . wrapT = wrapT ;
49+ texture . magFilter = magFilter ;
50+ texture . minFilter = minFilter ;
4251 texture . anisotropy = anisotropy ;
52+ texture . needsUpdate = true ;
4353 }
4454}
4555module . exports . setTextureProperties = setTextureProperties ;
0 commit comments