|
@@ -793,26 +793,38 @@ THREE.CanvasRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function onTextureUpdate ( event ) {
|
|
|
+
|
|
|
+ textureToPattern( event.target );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function textureToPattern( texture ) {
|
|
|
+
|
|
|
+ var repeatX = texture.wrapS === THREE.RepeatWrapping;
|
|
|
+ var repeatY = texture.wrapT === THREE.RepeatWrapping;
|
|
|
+
|
|
|
+ _patterns[ texture.id ] = _context.createPattern(
|
|
|
+ texture.image, repeatX === true && repeatY === true
|
|
|
+ ? 'repeat'
|
|
|
+ : repeatX === true && repeatY === false
|
|
|
+ ? 'repeat-x'
|
|
|
+ : repeatX === false && repeatY === true
|
|
|
+ ? 'repeat-y'
|
|
|
+ : 'no-repeat'
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function patternPath( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, texture ) {
|
|
|
|
|
|
if ( texture instanceof THREE.DataTexture || texture.image === undefined || texture.image.width === 0 ) return;
|
|
|
|
|
|
- if ( texture.needsUpdate === true ) {
|
|
|
-
|
|
|
- var repeatX = texture.wrapS === THREE.RepeatWrapping;
|
|
|
- var repeatY = texture.wrapT === THREE.RepeatWrapping;
|
|
|
+ if ( texture.hasEventListener( 'update', onTextureUpdate ) === false ) {
|
|
|
|
|
|
- _patterns[ texture.id ] = _context.createPattern(
|
|
|
- texture.image, repeatX === true && repeatY === true
|
|
|
- ? 'repeat'
|
|
|
- : repeatX === true && repeatY === false
|
|
|
- ? 'repeat-x'
|
|
|
- : repeatX === false && repeatY === true
|
|
|
- ? 'repeat-y'
|
|
|
- : 'no-repeat'
|
|
|
- );
|
|
|
+ textureToPattern( texture );
|
|
|
|
|
|
- texture.needsUpdate = false;
|
|
|
+ texture.addEventListener( 'update', onTextureUpdate );
|
|
|
|
|
|
}
|
|
|
|