Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Texture map options not parsed from mtl file #371

Closed
Erik8309 opened this issue Mar 22, 2023 · 3 comments
Closed

Texture map options not parsed from mtl file #371

Erik8309 opened this issue Mar 22, 2023 · 3 comments

Comments

@Erik8309
Copy link

Erik8309 commented Mar 22, 2023

Describe the bug
I want to apply options to my material in accordance with the mtl specification.
So for instance I have this material definition in my mtl file:

newmtl Herman_Miller_-_Seat_Fabric_8T07_Crossing_Pumpkin
Kd 1 1 1
d 1.000000
map_Kd -s 10 10 10 leather.mpc

The line with map_Kd points to the texture map and its options. However the texture is only read if there are no options in front of the texture. When adding options, the texture file cannot be found.
image

To Reproduce
Take any mtl and try to add a texture with scale or any other options.

Expected behavior
That the texture is read and scaled accordingly (or any other options applied).
I have tested it with blender and the texture with its options is read there.

Screenshots
image

@kovacsv
Copy link
Owner

kovacsv commented Mar 22, 2023

Could you please attach an example model (with obj, mtl and textures)?

@Erik8309
Copy link
Author

Erik8309 commented Mar 22, 2023

leather.zip

Sure, here is a zipfile that Im testing with.
I looked at the source code after filing the bug report and it looks like (Im much more familiar with c#) that the constructor for the TextureMap object (in here: https://github.com/kovacsv/Online3DViewer/blob/master/source/engine/model/material.js) does not parse the options, and sets a default scale here:

    constructor ()
    {
        this.name = null;
        this.mimeType = null;
        this.buffer = null;
        this.offset = new Coord2D (0.0, 0.0);
        this.scale = new Coord2D (1.0, 1.0);
        this.rotation = 0.0; // radians
    }

Then the CreateTexture function (in here: https://github.com/kovacsv/Online3DViewer/blob/master/source/engine/import/importerobj.js) only sets the buffer and name:

        function CreateTexture (keyword, line, callbacks)
        {
            let texture = new TextureMap ();
            let textureName = NameFromLine (line, keyword.length, '#');
            let textureBuffer = callbacks.getFileBuffer (textureName);
            texture.name = textureName;
            texture.buffer = textureBuffer;
            return texture;
        }

Thank you for your swift reply!

@kovacsv kovacsv added this to the Online3DViewer 0.8.23 milestone Mar 22, 2023
@kovacsv kovacsv changed the title Texture map options not parsed mtl file Texture map options not parsed from mtl file Mar 22, 2023
@kovacsv
Copy link
Owner

kovacsv commented Mar 22, 2023

Thanks for the report. It's fixed and should work from the next release.

@kovacsv kovacsv closed this as completed Mar 22, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants