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

WebGLTextures: More flexible image dimensions computation. #27810

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Feb 23, 2024

Fixed #23164.
Fixed #27783.

Description

The above issues convinced me to make the renderer a bit more flexible in the way it derives image dimensions. This PR introduces a new function in WebGLTextures called getDimensions() that derives the image dimensions depending on the image type. So width and height are still the defaults but instances of HTMLImageElement now use naturalWidth and naturalHeight if available. Instances of VideoFrame are now supported by using displayWidth and displayHeight.

To minimize the change set, getDimensions() is only used at places in WebGLTextures where instances of HTMLImageElement or VideoFrame can actually occur. So e.g. not in the code paths for data or compressed textures.

Copy link

github-actions bot commented Feb 23, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
678.1 kB (168.6 kB) 678.6 kB (168.7 kB) +440 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
458.5 kB (111.3 kB) 458.9 kB (111.4 kB) +450 B
@Mugen87 Mugen87 marked this pull request as ready for review February 23, 2024 10:33
@WestLangley WestLangley changed the title WebGLTextures: More flexibel image dimensions computation. Feb 23, 2024
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Feb 24, 2024

Side note: If it turns out in production that this change works well, we can adapt the same policy to WebGPURenderer.

@Mugen87 Mugen87 added this to the r162 milestone Feb 24, 2024
@Mugen87 Mugen87 merged commit d5a0288 into mrdoob:dev Feb 26, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants