MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / renderParticle

Function renderParticle

Three.js/js/Three62dev.js:15689–15802  ·  view source on GitHub ↗
( v1, element, material )

Source from the content-addressed store, hash-verified

15687 }
15688
15689 function renderParticle( v1, element, material ) {
15690
15691 setOpacity( material.opacity );
15692 setBlending( material.blending );
15693
15694 var width, height, scaleX, scaleY,
15695 bitmap, bitmapWidth, bitmapHeight;
15696
15697 if ( material instanceof THREE.ParticleBasicMaterial ) {
15698
15699 if ( material.map === null ) {
15700
15701 scaleX = element.object.scale.x;
15702 scaleY = element.object.scale.y;
15703
15704 // TODO: Be able to disable this
15705
15706 scaleX *= element.scale.x * _canvasWidthHalf;
15707 scaleY *= element.scale.y * _canvasHeightHalf;
15708
15709 _elemBox.min.set( v1.x - scaleX, v1.y - scaleY );
15710 _elemBox.max.set( v1.x + scaleX, v1.y + scaleY );
15711
15712 if ( _clipBox.isIntersectionBox( _elemBox ) === false ) {
15713
15714 _elemBox.makeEmpty();
15715 return;
15716
15717 }
15718
15719 setFillStyle( material.color.getStyle() );
15720
15721 _context.save();
15722 _context.translate( v1.x, v1.y );
15723 _context.rotate( - element.rotation );
15724 _context.scale( scaleX, scaleY );
15725 _context.fillRect( -1, -1, 2, 2 );
15726 _context.restore();
15727
15728 } else {
15729
15730 bitmap = material.map.image;
15731 bitmapWidth = bitmap.width >> 1;
15732 bitmapHeight = bitmap.height >> 1;
15733
15734 scaleX = element.scale.x * _canvasWidthHalf;
15735 scaleY = element.scale.y * _canvasHeightHalf;
15736
15737 width = scaleX * bitmapWidth;
15738 height = scaleY * bitmapHeight;
15739
15740 // TODO: Rotations break this...
15741
15742 _elemBox.min.set( v1.x - width, v1.y - height );
15743 _elemBox.max.set( v1.x + width, v1.y + height );
15744
15745 if ( _clipBox.isIntersectionBox( _elemBox ) === false ) {
15746

Callers 1

Three62dev.jsFile · 0.70

Calls 4

setOpacityFunction · 0.70
setBlendingFunction · 0.70
setFillStyleFunction · 0.70
setStrokeStyleFunction · 0.70

Tested by

no test coverage detected