@@ -19,7 +19,6 @@ THREE.SVGRenderer = function () {
1919
2020 _color = new THREE . Color ( ) ,
2121 _diffuseColor = new THREE . Color ( ) ,
22- _emissiveColor = new THREE . Color ( ) ,
2322 _ambientLight = new THREE . Color ( ) ,
2423 _directionalLights = new THREE . Color ( ) ,
2524 _pointLights = new THREE . Color ( ) ,
@@ -80,6 +79,10 @@ THREE.SVGRenderer = function () {
8079
8180 this . clear = function ( ) {
8281
82+ _pathCount = 0 ;
83+ _circleCount = 0 ;
84+ _lineCount = 0 ;
85+
8386 while ( _svg . childNodes . length > 0 ) {
8487
8588 _svg . removeChild ( _svg . childNodes [ 0 ] ) ;
@@ -97,9 +100,7 @@ THREE.SVGRenderer = function () {
97100
98101 }
99102
100- var e , el , element , material ;
101-
102- this . autoClear && this . clear ( ) ;
103+ if ( this . autoClear === true ) this . clear ( ) ;
103104
104105 _this . info . render . vertices = 0 ;
105106 _this . info . render . faces = 0 ;
@@ -108,15 +109,12 @@ THREE.SVGRenderer = function () {
108109 _elements = _renderData . elements ;
109110 _lights = _renderData . lights ;
110111
111- _pathCount = 0 ; _circleCount = 0 ; _lineCount = 0 ;
112-
113112 calculateLights ( _lights ) ;
114113
115- for ( e = 0 , el = _elements . length ; e < el ; e ++ ) {
116-
117- element = _elements [ e ] ;
114+ for ( var e = 0 , el = _elements . length ; e < el ; e ++ ) {
118115
119- material = element . material ;
116+ var element = _elements [ e ] ;
117+ var material = element . material ;
120118
121119 if ( material === undefined || material . visible === false ) continue ;
122120
@@ -127,7 +125,7 @@ THREE.SVGRenderer = function () {
127125 _v1 = element ;
128126 _v1 . x *= _svgWidthHalf ; _v1 . y *= - _svgHeightHalf ;
129127
130- renderParticle ( _v1 , element , material , scene ) ;
128+ renderParticle ( _v1 , element , material ) ;
131129
132130 } else if ( element instanceof THREE . RenderableLine ) {
133131
@@ -140,7 +138,7 @@ THREE.SVGRenderer = function () {
140138
141139 if ( _clipBox . isIntersectionBox ( _elemBox ) === true ) {
142140
143- renderLine ( _v1 , _v2 , element , material , scene ) ;
141+ renderLine ( _v1 , _v2 , element , material ) ;
144142
145143 }
146144
@@ -158,7 +156,7 @@ THREE.SVGRenderer = function () {
158156
159157 _elemBox . setFromPoints ( [ _v1 . positionScreen , _v2 . positionScreen , _v3 . positionScreen ] ) ;
160158
161- renderFace3 ( _v1 , _v2 , _v3 , element , material , scene ) ;
159+ renderFace3 ( _v1 , _v2 , _v3 , element , material ) ;
162160
163161 } else if ( element instanceof THREE . RenderableFace4 ) {
164162
@@ -176,7 +174,7 @@ THREE.SVGRenderer = function () {
176174
177175 _elemBox . setFromPoints ( [ _v1 . positionScreen , _v2 . positionScreen , _v3 . positionScreen , _v4 . positionScreen ] ) ;
178176
179- renderFace4 ( _v1 , _v2 , _v3 , _v4 , element , material , scene ) ;
177+ renderFace4 ( _v1 , _v2 , _v3 , _v4 , element , material ) ;
180178
181179 }
182180
@@ -186,16 +184,14 @@ THREE.SVGRenderer = function () {
186184
187185 function calculateLights ( lights ) {
188186
189- var l , ll , light , lightColor ;
190-
191187 _ambientLight . setRGB ( 0 , 0 , 0 ) ;
192188 _directionalLights . setRGB ( 0 , 0 , 0 ) ;
193189 _pointLights . setRGB ( 0 , 0 , 0 ) ;
194190
195- for ( l = 0 , ll = lights . length ; l < ll ; l ++ ) {
191+ for ( var l = 0 , ll = lights . length ; l < ll ; l ++ ) {
196192
197- light = lights [ l ] ;
198- lightColor = light . color ;
193+ var light = lights [ l ] ;
194+ var lightColor = light . color ;
199195
200196 if ( light instanceof THREE . AmbientLight ) {
201197
@@ -266,7 +262,7 @@ THREE.SVGRenderer = function () {
266262
267263 }
268264
269- function renderParticle ( v1 , element , material , scene ) {
265+ function renderParticle ( v1 , element , material ) {
270266
271267 /*
272268 _svgNode = getCircleNode( _circleCount++ );
@@ -295,7 +291,7 @@ THREE.SVGRenderer = function () {
295291
296292 }
297293
298- function renderLine ( v1 , v2 , element , material , scene ) {
294+ function renderLine ( v1 , v2 , element , material ) {
299295
300296 _svgNode = getLineNode ( _lineCount ++ ) ;
301297
@@ -314,7 +310,7 @@ THREE.SVGRenderer = function () {
314310
315311 }
316312
317- function renderFace3 ( v1 , v2 , v3 , element , material , scene ) {
313+ function renderFace3 ( v1 , v2 , v3 , element , material ) {
318314
319315 _this . info . render . vertices += 3 ;
320316 _this . info . render . faces ++ ;
@@ -332,10 +328,9 @@ THREE.SVGRenderer = function () {
332328
333329 }
334330
335- } else if ( material instanceof THREE . MeshLambertMaterial ) {
331+ } else if ( material instanceof THREE . MeshLambertMaterial || material instanceof THREE . MeshPhongMaterial ) {
336332
337333 _diffuseColor . copy ( material . color ) ;
338- _emissiveColor . copy ( material . emissive ) ;
339334
340335 if ( material . vertexColors === THREE . FaceColors ) {
341336
@@ -347,7 +342,7 @@ THREE.SVGRenderer = function () {
347342
348343 calculateLight ( _lights , element . centroidModel , element . normalModel , _color ) ;
349344
350- _color . multiply ( _diffuseColor ) . add ( _emissiveColor ) ;
345+ _color . multiply ( _diffuseColor ) . add ( material . emissive ) ;
351346
352347 } else if ( material instanceof THREE . MeshDepthMaterial ) {
353348
@@ -376,7 +371,7 @@ THREE.SVGRenderer = function () {
376371
377372 }
378373
379- function renderFace4 ( v1 , v2 , v3 , v4 , element , material , scene ) {
374+ function renderFace4 ( v1 , v2 , v3 , v4 , element , material ) {
380375
381376 _this . info . render . vertices += 4 ;
382377 _this . info . render . faces ++ ;
@@ -394,10 +389,9 @@ THREE.SVGRenderer = function () {
394389
395390 }
396391
397- } else if ( material instanceof THREE . MeshLambertMaterial ) {
392+ } else if ( material instanceof THREE . MeshLambertMaterial || material instanceof THREE . MeshPhongMaterial ) {
398393
399394 _diffuseColor . copy ( material . color ) ;
400- _emissiveColor . copy ( material . emissive ) ;
401395
402396 if ( material . vertexColors === THREE . FaceColors ) {
403397
@@ -409,7 +403,7 @@ THREE.SVGRenderer = function () {
409403
410404 calculateLight ( _lights , element . centroidModel , element . normalModel , _color ) ;
411405
412- _color . multiply ( _diffuseColor ) . add ( _emissiveColor ) ;
406+ _color . multiply ( _diffuseColor ) . add ( material . emissive ) ;
413407
414408 } else if ( material instanceof THREE . MeshDepthMaterial ) {
415409
0 commit comments