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

MMDLoader: Skip transparency check for CompressedTexture. #21878

Merged
merged 4 commits into from
May 24, 2021

Conversation

bill42362
Copy link
Contributor

Related issue: #17974

Description

I got this similar error when load MMD model with .dds texture:

MMDLoader.js?aed8:1456 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas or VideoFrame)'
    at createImageData (MMDLoader.js?aed8:1456)
    at Array.eval (MMDLoader.js?aed8:1524)
    at eval (MMDLoader.js?aed8:1406)
    at Object.eval [as onLoad] (three.module.js?5a89:35025)
    at XMLHttpRequest.eval (three.module.js?5a89:34742)

And I found if there's data property inside image object, MMDLoader:L1316 would just use it to check transparent, which could bypass process to get image data via <canvas>.

First time to make PR to opensource projects, hope this could help.

@Mugen87
Copy link
Collaborator

Mugen87 commented May 23, 2021

I think this problems should be solved in MMDLoader instead.

I also doubt that detectImageTransparency() will work with a compressed texture.

@bill42362 bill42362 changed the title CompressedTextureLoader: put first mipmap data into image to simulate ImageData. MMDLoader: Skip transparency check for CompressedTexture. May 23, 2021
@bill42362
Copy link
Contributor Author

@Mugen87 Thanks for your comment!

I've change the fix into MMDLoader, but I don't know better ways to check transparency of compressed textures.
So it's just a quick fix, which only set transparent to false for non-alpha channel formats.

@Mugen87 Mugen87 requested a review from takahirox May 23, 2021 17:55
Copy link
Collaborator

@takahirox takahirox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as @Mugen87 mentioned I don't think detectImageTransparency() works for compressed texture. So this workaround looks good to me (for now). Thanks!

@mrdoob mrdoob added this to the r129 milestone May 24, 2021
@mrdoob mrdoob merged commit 0a0c215 into mrdoob:dev May 24, 2021
@mrdoob
Copy link
Owner

mrdoob commented May 24, 2021

Thanks!

@bill42362 bill42362 deleted the CompressedTextureLoader branch May 24, 2021 13:17
@bill42362 bill42362 restored the CompressedTextureLoader branch May 25, 2021 18:15
@bill42362 bill42362 deleted the CompressedTextureLoader branch May 25, 2021 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants