mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.81k stars 35.38k forks source link

MTLLoader: Add support for TGA textures #5141

Closed jothikannan closed 5 years ago

jothikannan commented 10 years ago

am loading a model with the OBJMTLLoder. and am using .tga materials, the model is loaded as black.

three.js doesn't support .tga materials, what are the materials is supported by the three.js., can anyone tell me??

WestLangley commented 10 years ago

See the TGALoader example: https://threejs.org/examples/webgl_loader_texture_tga.html

Also check out the other loaders in the source code and examples.

jothikannan commented 10 years ago

ok am requesting a feature to use TGALoader combined with the OBJMTLLoder, that would be better if we use Wavefront OBJ models with the tga as materials

gengxuelei commented 7 years ago

is supported now?@jothikannan

Mugen87 commented 5 years ago

You should be able to load TGA textures with MTLLoader like so:

const manager = new THREE.LoadingManager();
manager.addHandler( /\.tga$/i, new THREE.TGALoader() );
const loader = new THREE.MTLLoader( manager );

// now load your MTL/OBJ files
WestLangley commented 5 years ago

manager.addHandler( /.tga$/i, new THREE.TGALoader() );

@Mugen87 I believe there is currently only one example of using .addHandler. Perhaps the docs can be made more descriptive -- or we can add an example of the use case you mentioned.

... or add the above line to the existing example and comment it out.

Mugen87 commented 5 years ago

I believe there is currently only one example of using .addHandler.

That's correct. It's the OBJ/MTL example which adds DDSLoader in this way.

Perhaps the docs can be made more descriptive

TBH, I think the description is already quite good. Do you have any idea how to improve it?

https://raw.githack.com/mrdoob/three.js/dev/docs/index.html#api/en/loaders/managers/LoadingManager.addHandler

Mugen87 commented 5 years ago

... or add the above line to the existing example and comment it out.

Done!

WestLangley commented 5 years ago

Do you have any idea how to improve it?

Not really, but this line seems to be a bit contradictory:

Note: The following methods are designed to be called internally by loaders. You shouldn't call them directly.

Mugen87 commented 5 years ago

Oh, I was not aware of this note! Let's reorganize this doc page.

WestLangley commented 5 years ago

Do you have any idea how to improve it?

Registers a loader with the given regular expression. 

@Mugen87 Without a pattern to follow, I would have no idea what that means or what the expression should look like.

If it is hard to explain, then a code snippet can be used... or a reference to an example, if we want to go that route.