MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / patternPath

Function patternPath

Three.js/js/Three62dev.js:16072–16164  ·  view source on GitHub ↗
( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, texture )

Source from the content-addressed store, hash-verified

16070 }
16071
16072 function patternPath( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, texture ) {
16073
16074 if ( texture instanceof THREE.DataTexture || texture.image === undefined || texture.image.width == 0 ) return;
16075
16076 if ( texture.needsUpdate === true ) {
16077
16078 var repeatX = texture.wrapS == THREE.RepeatWrapping;
16079 var repeatY = texture.wrapT == THREE.RepeatWrapping;
16080
16081 _patterns[ texture.id ] = _context.createPattern(
16082 texture.image, repeatX === true && repeatY === true
16083 ? 'repeat'
16084 : repeatX === true && repeatY === false
16085 ? 'repeat-x'
16086 : repeatX === false && repeatY === true
16087 ? 'repeat-y'
16088 : 'no-repeat'
16089 );
16090
16091 texture.needsUpdate = false;
16092
16093 }
16094
16095 _patterns[ texture.id ] === undefined
16096 ? setFillStyle( 'rgba(0,0,0,1)' )
16097 : setFillStyle( _patterns[ texture.id ] );
16098
16099 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
16100
16101 var a, b, c, d, e, f, det, idet,
16102 offsetX = texture.offset.x / texture.repeat.x,
16103 offsetY = texture.offset.y / texture.repeat.y,
16104 width = texture.image.width * texture.repeat.x,
16105 height = texture.image.height * texture.repeat.y;
16106
16107 u0 = ( u0 + offsetX ) * width;
16108 v0 = ( 1.0 - v0 + offsetY ) * height;
16109
16110 u1 = ( u1 + offsetX ) * width;
16111 v1 = ( 1.0 - v1 + offsetY ) * height;
16112
16113 u2 = ( u2 + offsetX ) * width;
16114 v2 = ( 1.0 - v2 + offsetY ) * height;
16115
16116 x1 -= x0; y1 -= y0;
16117 x2 -= x0; y2 -= y0;
16118
16119 u1 -= u0; v1 -= v0;
16120 u2 -= u0; v2 -= v0;
16121
16122 det = u1 * v2 - u2 * v1;
16123
16124 if ( det === 0 ) {
16125
16126 if ( _imagedatas[ texture.id ] === undefined ) {
16127
16128 var canvas = document.createElement( 'canvas' )
16129 canvas.width = texture.image.width;

Callers 1

renderFace3Function · 0.70

Calls 2

setFillStyleFunction · 0.70
fillPathFunction · 0.70

Tested by

no test coverage detected