提交 f9067c0d 编写于 作者: M Mugen87

ColladaLoader: Added support for TGA-textures

上级 61f08e8f
......@@ -969,11 +969,11 @@ THREE.ColladaLoader.prototype = {
if ( data.bindShapeMatrix ) {
build.bindMatrix = new THREE.Matrix4().fromArray( data.bindShapeMatrix ).transpose();
build.bindMatrix = new THREE.Matrix4().fromArray( data.bindShapeMatrix ).transpose();
} else {
build.bindMatrix = new THREE.Matrix4().transpose();
build.bindMatrix = new THREE.Matrix4().transpose();
}
......@@ -1449,6 +1449,28 @@ THREE.ColladaLoader.prototype = {
}
function getTextureLoader( image ) {
var loader;
var extension = image.slice( ( image.lastIndexOf( '.' ) - 1 >>> 0 ) + 2 ); // http://www.jstips.co/en/javascript/get-file-extension/
extension = extension.toLowerCase();
switch ( extension ) {
case 'tga':
loader = tgaLoader;
break;
default:
loader = textureLoader;
}
return loader;
}
function buildMaterial( data ) {
var effect = getEffect( data.url );
......@@ -1499,28 +1521,40 @@ THREE.ColladaLoader.prototype = {
if ( image !== null ) {
var texture = textureLoader.load( image );
var loader = getTextureLoader( image );
if ( loader !== undefined ) {
var extra = textureObject.extra;
var texture = loader.load( image );
if ( extra !== undefined && extra.technique !== undefined && isEmpty( extra.technique ) === false ) {
var extra = textureObject.extra;
var technique = extra.technique;
if ( extra !== undefined && extra.technique !== undefined && isEmpty( extra.technique ) === false ) {
texture.wrapS = technique.wrapU ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
texture.wrapT = technique.wrapV ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
var technique = extra.technique;
texture.offset.set( technique.offsetU || 0, technique.offsetV || 0 );
texture.repeat.set( technique.repeatU || 1, technique.repeatV || 1 );
texture.wrapS = technique.wrapU ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
texture.wrapT = technique.wrapV ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
texture.offset.set( technique.offsetU || 0, technique.offsetV || 0 );
texture.repeat.set( technique.repeatU || 1, technique.repeatV || 1 );
} else {
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
}
return texture;
} else {
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
console.warn( 'THREE.ColladaLoader: Loader for texture %s not found.', image );
}
return null;
return texture;
}
} else {
......@@ -3769,6 +3803,15 @@ THREE.ColladaLoader.prototype = {
var textureLoader = new THREE.TextureLoader( this.manager );
textureLoader.setPath( path ).setCrossOrigin( this.crossOrigin );
var tgaLoader;
if ( THREE.TGALoader ) {
tgaLoader = new THREE.TGALoader( this.manager );
tgaLoader.setPath( path );
}
//
var animations = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册