MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / patternPath

Function patternPath

Three.js/js/ThreeDebug.js:9896–9981  ·  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

9894 }
9895
9896 function patternPath( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, texture ) {
9897
9898 if ( texture.image.width == 0 ) return;
9899
9900 if ( texture.needsUpdate == true || _patterns[ texture.id ] == undefined ) {
9901
9902 var repeatX = texture.wrapS == THREE.RepeatWrapping;
9903 var repeatY = texture.wrapT == THREE.RepeatWrapping;
9904
9905 _patterns[ texture.id ] = _context.createPattern( texture.image, repeatX && repeatY ? 'repeat' : repeatX && !repeatY ? 'repeat-x' : !repeatX && repeatY ? 'repeat-y' : 'no-repeat' );
9906
9907 texture.needsUpdate = false;
9908
9909 }
9910
9911 setFillStyle( _patterns[ texture.id ] );
9912
9913 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
9914
9915 var a, b, c, d, e, f, det, idet,
9916 offsetX = texture.offset.x / texture.repeat.x,
9917 offsetY = texture.offset.y / texture.repeat.y,
9918 width = texture.image.width * texture.repeat.x,
9919 height = texture.image.height * texture.repeat.y;
9920
9921 u0 = ( u0 + offsetX ) * width;
9922 v0 = ( v0 + offsetY ) * height;
9923
9924 u1 = ( u1 + offsetX ) * width;
9925 v1 = ( v1 + offsetY ) * height;
9926
9927 u2 = ( u2 + offsetX ) * width;
9928 v2 = ( v2 + offsetY ) * height;
9929
9930 x1 -= x0; y1 -= y0;
9931 x2 -= x0; y2 -= y0;
9932
9933 u1 -= u0; v1 -= v0;
9934 u2 -= u0; v2 -= v0;
9935
9936 det = u1 * v2 - u2 * v1;
9937
9938 if ( det == 0 ) {
9939
9940 if ( _imagedatas[ texture.id ] === undefined ) {
9941
9942 var canvas = document.createElement( 'canvas' )
9943 canvas.width = texture.image.width;
9944 canvas.height = texture.image.height;
9945
9946 var context = canvas.getContext( '2d' );
9947 context.drawImage( texture.image, 0, 0 );
9948
9949 _imagedatas[ texture.id ] = context.getImageData( 0, 0, texture.image.width, texture.image.height ).data;
9950
9951 // variables cannot be deleted in ES5 strict mode
9952 //delete canvas;
9953

Callers 1

renderFace3Function · 0.70

Calls 2

setFillStyleFunction · 0.70
fillPathFunction · 0.70

Tested by

no test coverage detected