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

Texture: Add WorldMapping to use world coordinates for texturing (#18992) #19010

Closed
wants to merge 16 commits into from
Closed

Conversation

finnbear
Copy link
Sponsor Contributor

@finnbear finnbear commented Apr 1, 2020

This PR adds THREE.WorldMapping, an alternative to THREE.UVMapping. WorldMapping works by using two (user defined) axes of the vertex's world coordinates as the UV coordinates for texture mapping. It is configurable via the API:

mesh.worldMappingAxes = 'xz'; // the default
mesh.material.map.mapping = THREE.WorldMapping;

This is crucial for applying "seamless" textures to grids of non-square objects without manually setting the UVs of each one. As a result, InstancedMesh is supported.

The changes don't break any of the examples I tried running.

A working example is available: webgl_materials_texture_worldmapping
image

Please see #18992 for more details.

Warning: This is my first PR on this repository and the biggest PR I have ever written for any repository. It may break things. Please merge with caution. Suggestions for changes/fixes welcome.

@finnbear
Copy link
Sponsor Contributor Author

finnbear commented Apr 1, 2020

Thanks for adding a live link. I'm in the process of adding my build from this PR to my application to see if it actually solves my problem 😉. There seems like there might be an issue so hold off on merging for now. Comments are welcome though.

@finnbear
Copy link
Sponsor Contributor Author

finnbear commented Apr 1, 2020

Okay, after some fixes, there are no remaining issues with my app. This is mergable AFAIK 😄

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 1, 2020

see #18992 (comment)

@finnbear
Copy link
Sponsor Contributor Author

finnbear commented Apr 1, 2020

see #18992 (comment), in response to previous comment

@gkjohnson
Copy link
Collaborator

I agree that this is application specific and doesn't belong in core -- I think node materials or ShaderMaterials serve this use case well.

@finnbear
Copy link
Sponsor Contributor Author

finnbear commented Apr 1, 2020

Okay, let's close this and finalize discussion in the issue.

@finnbear finnbear closed this Apr 1, 2020
@WestLangley
Copy link
Collaborator

Removed temporary live link.

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.

None yet

4 participants