@@ -402,28 +402,35 @@ THREE.ColladaExporter.prototype = {
402402
403403 '</emission>' +
404404
405- '<diffuse>' +
406-
407405 (
408- m . map ?
409- '<texture texture="diffuse-sampler" texcoord="TEXCOORD" />' :
410- `<color sid="diffuse">${ diffuse . r } ${ diffuse . g } ${ diffuse . b } 1</color>`
406+ type !== 'constant' ?
407+ '<diffuse>' +
408+
409+ (
410+ m . map ?
411+ '<texture texture="diffuse-sampler" texcoord="TEXCOORD" />' :
412+ `<color sid="diffuse">${ diffuse . r } ${ diffuse . g } ${ diffuse . b } 1</color>`
413+ ) +
414+ '</diffuse>'
415+ : ''
411416 ) +
412417
413- '</diffuse>' +
418+ (
419+ type === 'phong' ?
420+ `<specular><color sid="specular">${ specular . r } ${ specular . g } ${ specular . b } 1</color></specular>` +
414421
415- `<specular><color sid="specular"> ${ specular . r } ${ specular . g } ${ specular . b } 1</color></specular>` +
422+ '<shininess>' +
416423
417- '<shininess>' +
424+ (
425+ m . specularMap ?
426+ '<texture texture="specular-sampler" texcoord="TEXCOORD" />' :
427+ `<float sid="shininess">${ shininess } </float>`
428+ ) +
418429
419- (
420- m . specularMap ?
421- '<texture texture="specular-sampler" texcoord="TEXCOORD" />' :
422- `<float sid="shininess">${ shininess } </float>`
430+ '</shininess>'
431+ : ''
423432 ) +
424433
425- '</shininess>' +
426-
427434 `<reflective><color>${ diffuse . r } ${ diffuse . g } ${ diffuse . b } 1</color></reflective>` +
428435
429436 `<reflectivity><float>${ reflectivity } </float></reflectivity>` +
@@ -502,17 +509,21 @@ THREE.ColladaExporter.prototype = {
502509
503510 // ids of the materials to bind to the geometry
504511 var matids = null ;
512+ var matidsArray = [ ] ;
505513
506514 // get a list of materials to bind to the sub groups of the geometry.
507515 // If the amount of subgroups is greater than the materials, than reuse
508516 // the materials.
509517 var mat = o . material || new THREE . MeshBasicMaterial ( ) ;
510518 var materials = Array . isArray ( mat ) ? mat : [ mat ] ;
511- matids = new Array ( geometry . groups . length )
512- . fill ( )
519+ if ( geometry . groups . length > materials . length ) {
520+ matidsArray = new Array ( geometry . groups . length ) ;
521+ } else {
522+ matidsArray = new Array ( materials . length )
523+ }
524+ matids = matidsArray . fill ( )
513525 . map ( ( v , i ) => processMaterial ( materials [ i % materials . length ] ) ) ;
514526
515-
516527 node +=
517528 `<instance_geometry url="#${ meshid } ">` +
518529
0 commit comments