@@ -420,7 +420,87 @@ THREE.ColladaLoader.prototype = {
420420 break ;
421421
422422 case 'texture' :
423- data [ child . nodeName ] = child . getAttribute ( 'texture' ) ;
423+ data [ child . nodeName ] = { id : child . getAttribute ( 'texture' ) , extra : parseEffectParameterTexture ( child ) } ;
424+ break ;
425+
426+ }
427+
428+ }
429+
430+ return data ;
431+
432+ }
433+
434+ function parseEffectParameterTexture ( xml ) {
435+
436+ var data = { } ;
437+
438+ for ( var i = 0 , l = xml . childNodes . length ; i < l ; i ++ ) {
439+
440+ var child = xml . childNodes [ i ] ;
441+
442+ if ( child . nodeType !== 1 ) continue ;
443+
444+ switch ( child . nodeName ) {
445+
446+ case 'extra' :
447+ data = parseEffectParameterTextureExtra ( child ) ;
448+ break ;
449+
450+ }
451+
452+ }
453+
454+ return data ;
455+
456+ }
457+
458+ function parseEffectParameterTextureExtra ( xml ) {
459+
460+ var data = { } ;
461+
462+ for ( var i = 0 , l = xml . childNodes . length ; i < l ; i ++ ) {
463+
464+ var child = xml . childNodes [ i ] ;
465+
466+ if ( child . nodeType !== 1 ) continue ;
467+
468+ switch ( child . nodeName ) {
469+
470+ case 'technique' :
471+ data [ child . nodeName ] = parseEffectParameterTextureExtraTechnique ( child ) ;
472+ break ;
473+
474+ }
475+
476+ }
477+
478+ return data ;
479+
480+ }
481+
482+ function parseEffectParameterTextureExtraTechnique ( xml ) {
483+
484+ var data = { } ;
485+
486+ for ( var i = 0 , l = xml . childNodes . length ; i < l ; i ++ ) {
487+
488+ var child = xml . childNodes [ i ] ;
489+
490+ if ( child . nodeType !== 1 ) continue ;
491+
492+ switch ( child . nodeName ) {
493+
494+ case 'repeatU' :
495+ case 'repeatV' :
496+ case 'offsetU' :
497+ case 'offsetV' :
498+ data [ child . nodeName ] = parseFloat ( child . textContent ) ;
499+ break ;
500+
501+ case 'wrapU' :
502+ case 'wrapV' :
503+ data [ child . nodeName ] = parseInt ( child . textContent ) ;
424504 break ;
425505
426506 }
@@ -497,24 +577,37 @@ THREE.ColladaLoader.prototype = {
497577
498578 material . name = data . name ;
499579
500- function getTexture ( sid ) {
580+ function getTexture ( textureObject ) {
501581
502- var sampler = effect . profile . samplers [ sid ] ;
582+ var sampler = effect . profile . samplers [ textureObject . id ] ;
503583
504584 if ( sampler !== undefined ) {
505585
506586 var surface = effect . profile . surfaces [ sampler . source ] ;
507587
508588 var texture = new THREE . Texture ( getImage ( surface . init_from ) ) ;
509- texture . wrapS = THREE . RepeatWrapping ;
510- texture . wrapT = THREE . RepeatWrapping ;
589+
590+ var extra = textureObject . extra ;
591+
592+ if ( extra !== undefined && extra . technique !== undefined ) {
593+
594+ var technique = extra . technique ;
595+
596+ texture . wrapS = technique . wrapU ? THREE . RepeatWrapping : THREE . ClampToEdgeWrapping ;
597+ texture . wrapT = technique . wrapV ? THREE . RepeatWrapping : THREE . ClampToEdgeWrapping ;
598+
599+ texture . offset . set ( technique . offsetU , technique . offsetV ) ;
600+ texture . repeat . set ( technique . repeatU , technique . repeatV ) ;
601+
602+ }
603+
511604 texture . needsUpdate = true ;
512605
513606 return texture ;
514607
515608 }
516609
517- console . error ( 'ColladaLoder: Undefined sampler' , sid ) ;
610+ console . error ( 'ColladaLoder: Undefined sampler' , textureObject . id ) ;
518611
519612 return null ;
520613
0 commit comments