|
@@ -420,7 +420,7 @@ THREE.ColladaLoader.prototype = {
|
|
|
break;
|
|
|
|
|
|
case 'texture':
|
|
|
- data[ child.nodeName ] = child.getAttribute( 'texture' );
|
|
|
+ data[ child.nodeName ] = { id: child.getAttribute( 'texture' ), extra: parseEffectParameterTexture( child ) };
|
|
|
break;
|
|
|
|
|
|
}
|
|
@@ -431,6 +431,98 @@ THREE.ColladaLoader.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function parseEffectParameterTexture( xml ) {
|
|
|
+
|
|
|
+ var data = {};
|
|
|
+
|
|
|
+ for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var child = xml.childNodes[ i ];
|
|
|
+
|
|
|
+ if ( child.nodeType !== 1 ) continue;
|
|
|
+
|
|
|
+ switch ( child.nodeName ) {
|
|
|
+
|
|
|
+ case 'extra':
|
|
|
+ data = parseEffectParameterTextureExtra( child );
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function parseEffectParameterTextureExtra( xml ) {
|
|
|
+
|
|
|
+ var data = {};
|
|
|
+
|
|
|
+ for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var child = xml.childNodes[ i ];
|
|
|
+
|
|
|
+ if ( child.nodeType !== 1 ) continue;
|
|
|
+
|
|
|
+ switch ( child.nodeName ) {
|
|
|
+
|
|
|
+ case 'technique':
|
|
|
+ data[ child.nodeName ] = parseEffectParameterTextureExtraTechnique( child );
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function parseEffectParameterTextureExtraTechnique( xml ) {
|
|
|
+
|
|
|
+ var data = {};
|
|
|
+
|
|
|
+ for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var child = xml.childNodes[ i ];
|
|
|
+
|
|
|
+ if ( child.nodeType !== 1 ) continue;
|
|
|
+
|
|
|
+ switch ( child.nodeName ) {
|
|
|
+
|
|
|
+ case 'repeatU':
|
|
|
+ data[ child.nodeName ] = parseFloat( child.textContent );
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'repeatV':
|
|
|
+ data[ child.nodeName ] = parseFloat( child.textContent );
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'offsetU':
|
|
|
+ data[ child.nodeName ] = parseFloat( child.textContent );
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'offsetV':
|
|
|
+ data[ child.nodeName ] = parseFloat( child.textContent );
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'wrapU':
|
|
|
+ data[ child.nodeName ] = parseInt( child.textContent );
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'wrapV':
|
|
|
+ data[ child.nodeName ] = parseInt( child.textContent );
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function buildEffect( data ) {
|
|
|
|
|
|
return data;
|
|
@@ -497,24 +589,37 @@ THREE.ColladaLoader.prototype = {
|
|
|
|
|
|
material.name = data.name;
|
|
|
|
|
|
- function getTexture( sid ) {
|
|
|
+ function getTexture( textureObject ) {
|
|
|
|
|
|
- var sampler = effect.profile.samplers[ sid ];
|
|
|
+ var sampler = effect.profile.samplers[ textureObject.id ];
|
|
|
|
|
|
if ( sampler !== undefined ) {
|
|
|
|
|
|
var surface = effect.profile.surfaces[ sampler.source ];
|
|
|
|
|
|
var texture = new THREE.Texture( getImage( surface.init_from ) );
|
|
|
- texture.wrapS = THREE.RepeatWrapping;
|
|
|
- texture.wrapT = THREE.RepeatWrapping;
|
|
|
+
|
|
|
+ //find techniques
|
|
|
+ if (textureObject.extra !== undefined) {
|
|
|
+ if (textureObject.extra.technique !== undefined) {
|
|
|
+ texture.wrapS = textureObject.extra.technique.wrapU ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
|
|
|
+ texture.wrapT = textureObject.extra.technique.wrapV ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
|
|
|
+ var offsetU = textureObject.extra.technique.offsetU;
|
|
|
+ var offsetV = textureObject.extra.technique.offsetV;
|
|
|
+ texture.offset.set(offsetU, offsetV);
|
|
|
+ var repeatU = textureObject.extra.technique.repeatU;
|
|
|
+ var repeatV = textureObject.extra.technique.repeatV;
|
|
|
+ texture.repeat.set(repeatU, repeatV);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
texture.needsUpdate = true;
|
|
|
|
|
|
return texture;
|
|
|
|
|
|
}
|
|
|
|
|
|
- console.error( 'ColladaLoder: Undefined sampler', sid );
|
|
|
+ console.error( 'ColladaLoder: Undefined sampler', textureObject.id );
|
|
|
|
|
|
return null;
|
|
|
|