Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Possible bug: Avocado example has negative texture co-ordinates #54

Closed
alteous opened this issue Jul 28, 2017 · 1 comment
Closed

Possible bug: Avocado example has negative texture co-ordinates #54

alteous opened this issue Jul 28, 2017 · 1 comment

Comments

@alteous
Copy link
Member

alteous commented Jul 28, 2017

Reproduce with:

fn main() {
    let gltf = gltf::Import::from_path("glTF-Sample-Models/2.0/Avocado/glTF/Avocado.gltf").sync().unwrap();
    let mesh = gltf.meshes().nth(0).unwrap();
    let primitive = mesh.primitives().nth(0).unwrap();
    let mut tex_coords = vec![];
    match primitive.tex_coords(0).unwrap() {
        gltf::mesh::TexCoords::U8(iter) => {
            for x in iter {
                tex_coords.push([x[0] as f32 / 255.0, x[1] as f32 / 255.0]);
            }
        },
        gltf::mesh::TexCoords::U16(iter) => {
            for x in iter {
                tex_coords.push([x[0] as f32 / 65535.0, x[1] as f32 / 65535.0]);
            }
        },
        gltf::mesh::TexCoords::F32(iter) => {
            for x in iter {
                tex_coords.push([x[0], x[1]]);
            }
        },
    }
    println!("{:?}", tex_coords);
}

Note that all the x[1] values are negative but otherwise valid in unit range.

@alteous
Copy link
Member Author

alteous commented Jul 28, 2017

Response from @lexaknyazev on Gitter:

UV coordinates wrapping follows OpenGL. Clients should use wrapping mode from sampler object (which could be omitted when default).

It looks like this isn't a bug after all.

@alteous alteous closed this as completed Jul 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant