|
@@ -26,8 +26,8 @@ THREE.SVGRenderer = function () {
|
|
|
_w, // z-buffer to w-buffer
|
|
|
_vector3 = new THREE.Vector3(), // Needed for PointLight
|
|
|
|
|
|
- _svgPathPool = [], _svgRectPool = [], _svgLinePool = [],
|
|
|
- _svgNode, _pathCount, _circleCount, _lineCount,
|
|
|
+ _svgPathPool = [], _svgLinePool = [], _svgRectPool = [],
|
|
|
+ _svgNode, _pathCount = 0, _lineCount = 0, _rectCount = 0,
|
|
|
_quality = 1;
|
|
|
|
|
|
this.domElement = _svg;
|
|
@@ -86,8 +86,8 @@ THREE.SVGRenderer = function () {
|
|
|
this.clear = function () {
|
|
|
|
|
|
_pathCount = 0;
|
|
|
- _circleCount = 0;
|
|
|
_lineCount = 0;
|
|
|
+ _rectCount = 0;
|
|
|
|
|
|
while ( _svg.childNodes.length > 0 ) {
|
|
|
|
|
@@ -129,7 +129,7 @@ THREE.SVGRenderer = function () {
|
|
|
if ( element instanceof THREE.RenderableSprite ) {
|
|
|
|
|
|
_v1 = element;
|
|
|
- _v1.x *= _svgWidthHalf; _v1.y *= -_svgHeightHalf;
|
|
|
+ _v1.x *= _svgWidthHalf; _v1.y *= - _svgHeightHalf;
|
|
|
|
|
|
renderSprite( _v1, element, material );
|
|
|
|
|
@@ -260,19 +260,15 @@ THREE.SVGRenderer = function () {
|
|
|
|
|
|
function renderSprite( v1, element, material ) {
|
|
|
|
|
|
- var scaleX = element.object.scale.x;
|
|
|
- var scaleY = element.object.scale.y;
|
|
|
+ var scaleX = element.scale.x * _svgWidthHalf;
|
|
|
+ var scaleY = element.scale.y * _svgHeightHalf;
|
|
|
|
|
|
- // TODO: Be able to disable this
|
|
|
+ _svgNode = getRectNode( _rectCount ++ );
|
|
|
|
|
|
- scaleX *= element.scale.x * _svgWidthHalf;
|
|
|
- scaleY *= element.scale.y * _svgHeightHalf;
|
|
|
-
|
|
|
- _svgNode = getRectNode( _circleCount++ );
|
|
|
- _svgNode.setAttribute( 'x', v1.x - scaleX );
|
|
|
- _svgNode.setAttribute( 'y', v1.y - scaleY );
|
|
|
- _svgNode.setAttribute( 'width', 2 * scaleX );
|
|
|
- _svgNode.setAttribute( 'height', 2 * scaleY );
|
|
|
+ _svgNode.setAttribute( 'x', v1.x - ( scaleX * 0.5 ) );
|
|
|
+ _svgNode.setAttribute( 'y', v1.y - ( scaleY * 0.5 ) );
|
|
|
+ _svgNode.setAttribute( 'width', scaleX );
|
|
|
+ _svgNode.setAttribute( 'height', scaleY );
|
|
|
|
|
|
if ( material instanceof THREE.SpriteMaterial ) {
|
|
|
|
|
@@ -284,7 +280,7 @@ THREE.SVGRenderer = function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function renderLine ( v1, v2, element, material ) {
|
|
|
+ function renderLine( v1, v2, element, material ) {
|
|
|
|
|
|
_svgNode = getLineNode( _lineCount ++ );
|
|
|
|
|
@@ -412,7 +408,7 @@ THREE.SVGRenderer = function () {
|
|
|
|
|
|
if ( _quality == 0 ) {
|
|
|
|
|
|
- _svgRectPool[id].setAttribute( 'shape-rendering', 'crispEdges' ); //optimizeSpeed
|
|
|
+ _svgRectPool[ id ].setAttribute( 'shape-rendering', 'crispEdges' ); //optimizeSpeed
|
|
|
|
|
|
}
|
|
|
|