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

Strange issues with MeshReflectorMaterial and GLB geometries #2032

Open
davcri opened this issue Jul 16, 2024 · 1 comment
Open

Strange issues with MeshReflectorMaterial and GLB geometries #2032

davcri opened this issue Jul 16, 2024 · 1 comment
Labels
question Further information is requested

Comments

@davcri
Copy link
Contributor

davcri commented Jul 16, 2024

I tried <MeshReflectorMaterial /> but I noticed a strange behaviour with geometries exported from Blender.

On the right I applied the material to a <planeGeometry /> and it works fine
On the left I applied the material to a Blender exported plane and the reflection is wrong.

image

MRE: https://codesandbox.io/p/sandbox/meshreflectormaterial-strange-behaviour-p63gh3?file=%2Fsrc%2FApp.js%3A33%2C31

Is this expected?

Just as a hint: I noticed that running this code "fixes" the reflection

function Comp() {
    const { nodes } = useGLTF('/models/plane.glb') // plane exported from Blender
    const planeThree = new PlaneGeometry(2, 2)
    const planeGLB = nodes['Plane']

    function fixGeom(g: BufferGeometry) {
        g.deleteAttribute('position')
        g.setAttribute('position', planeThree.attributes.position.clone())
        g.setIndex(planeThree.index!.clone()) // seems like position and index data is what differ from Blender and Three's planes
        g.computeVertexNormals()
    }

    fixGeom(planeGLB.geometry)
@davcri davcri added the question Further information is requested label Jul 16, 2024
@davcri
Copy link
Contributor Author

davcri commented Jul 16, 2024

I guess <MeshReflectorMaterial /> expects vertices to have a specific local space position (eg: similar to THREE's default planeGeometry): the reflections works fine when using a plane.glb exported with the rotation applied to the vertices of the geometry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant