@@ -26,7 +26,7 @@ THREE.SVGRenderer = function () {
2626 _w , // z-buffer to w-buffer
2727 _vector3 = new THREE . Vector3 ( ) , // Needed for PointLight
2828
29- _svgPathPool = [ ] , _svgCirclePool = [ ] , _svgLinePool = [ ] ,
29+ _svgPathPool = [ ] , _svgRectPool = [ ] , _svgLinePool = [ ] ,
3030 _svgNode , _pathCount , _circleCount , _lineCount ,
3131 _quality = 1 ;
3232
@@ -260,30 +260,27 @@ THREE.SVGRenderer = function () {
260260
261261 function renderSprite ( v1 , element , material ) {
262262
263- /*
264- _svgNode = getCircleNode( _circleCount++ );
265- _svgNode.setAttribute( 'cx', v1.x );
266- _svgNode.setAttribute( 'cy', v1.y );
267- _svgNode.setAttribute( 'r', element.scale.x * _svgWidthHalf );
263+ var scaleX = element . object . scale . x ;
264+ var scaleY = element . object . scale . y ;
268265
269- if ( material instanceof THREE.SpriteSVGMaterial ) {
266+ // TODO: Be able to disable this
270267
271- _color.r = _ambientLight.r + _directionalLights.r + _pointLights.r;
272- _color.g = _ambientLight.g + _directionalLights.g + _pointLights.g;
273- _color.b = _ambientLight.b + _directionalLights.b + _pointLights.b;
268+ scaleX *= element . scale . x * _svgWidthHalf ;
269+ scaleY *= element . scale . y * _svgHeightHalf ;
274270
275- _color.r = material.color.r * _color.r;
276- _color.g = material.color.g * _color.g;
277- _color.b = material.color.b * _color.b;
271+ _svgNode = getRectNode ( _circleCount ++ ) ;
272+ _svgNode . setAttribute ( 'x' , v1 . x - scaleX ) ;
273+ _svgNode . setAttribute ( 'y' , v1 . y - scaleY ) ;
274+ _svgNode . setAttribute ( 'width' , 2 * scaleX ) ;
275+ _svgNode . setAttribute ( 'height' , 2 * scaleY ) ;
278276
279- _color.updateStyleString();
277+ if ( material instanceof THREE . SpriteMaterial ) {
280278
281- _svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString );
279+ _svgNode . setAttribute ( 'style' , 'fill: ' + material . color . getStyle ( ) ) ;
282280
283281 }
284282
285283 _svg . appendChild ( _svgNode ) ;
286- */
287284
288285 }
289286
@@ -407,23 +404,23 @@ THREE.SVGRenderer = function () {
407404
408405 }
409406
410- function getCircleNode ( id ) {
407+ function getRectNode ( id ) {
411408
412- if ( _svgCirclePool [ id ] == null ) {
409+ if ( _svgRectPool [ id ] == null ) {
413410
414- _svgCirclePool [ id ] = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'circle ' ) ;
411+ _svgRectPool [ id ] = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'rect ' ) ;
415412
416413 if ( _quality == 0 ) {
417414
418- _svgCirclePool [ id ] . setAttribute ( 'shape-rendering' , 'crispEdges' ) ; //optimizeSpeed
415+ _svgRectPool [ id ] . setAttribute ( 'shape-rendering' , 'crispEdges' ) ; //optimizeSpeed
419416
420417 }
421418
422- return _svgCirclePool [ id ] ;
419+ return _svgRectPool [ id ] ;
423420
424421 }
425422
426- return _svgCirclePool [ id ] ;
423+ return _svgRectPool [ id ] ;
427424
428425 }
429426
0 commit comments