WIP: Added Texture.contain, .cover, .fill#17199
Closed
WestLangley wants to merge 5 commits intomrdoob:devfrom
Closed
WIP: Added Texture.contain, .cover, .fill#17199WestLangley wants to merge 5 commits intomrdoob:devfrom
WestLangley wants to merge 5 commits intomrdoob:devfrom
Conversation
WestLangley
commented
Aug 8, 2019
| void main() { | ||
|
|
||
| if ( vUv.x < 0.0 || vUv.x > 1.0 ) discard; // works, but it messes up repeated textures in other use cases | ||
| if ( vUv.y < 0.0 || vUv.y > 1.0 ) discard; |
Collaborator
Author
There was a problem hiding this comment.
This is required to support "contain". Is it worth supporting contain?
Collaborator
|
Perhaps import { Scene } from 'three';
import { SceneUtils } from 'three/examples/jsm/utils/SceneUtils.js';
const scene = new Scene();
scene.background = texture;
SceneUtils.setBackgroundFit( scene, 'contain', aspect ); |
Collaborator
Author
|
@donmccurdy That is probably better... |
Collaborator
Author
|
@mrdoob Maybe we could have a |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a flat texture is set as the scene.background, it stretches to fit by default.
I'm trying to find the right API to support something like the CSS object-fit "cover" and "contain" properties.
(This feature does not have to be supported by adding new methods to
Textureas I have done. I could just show an example.)Suggestions welcome...