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

WeakMap key must be an Object #1948

Open
fl1k opened this issue May 2, 2024 · 1 comment
Open

WeakMap key must be an Object #1948

fl1k opened this issue May 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fl1k
Copy link

fl1k commented May 2, 2024

  • three version: 0.164.1
  • @react-three/fiber version: 8.16.3
  • @react-three/drei version: 9.105.6
  • node version: 21.7,3
  • npm (or yarn) version: 10.5.2
  • Expo: 50.0.17

Problem description:

I am using Expo,
I keep getting this error every time I try using functionality of either fiber or drei
TypeError: WeakMap key must be an Object, js engine: hermes
From drei: import { Environment } from '@react-three/drei/native'
From fiber: useLoader(TextureLoader) - I fixed it by switching to three texture loading with new TextureLoader()

Relevant code:

  <View style={{flex: 3}}>
                        <Suspense>
                            <Canvas shadows
                                    onCreated={(state) => {
                                        const _gl = state.gl.getContext();
                                        const pixelStorei = _gl.pixelStorei.bind(_gl);
                                        _gl.pixelStorei = function (...args) {
                                            const [parameter] = args;
                                            switch (parameter) {
                                                case _gl.UNPACK_FLIP_Y_WEBGL:
                                                    return pixelStorei(...args);
                                            }
                                        };
                                    }}
                            >
                                <OrbitControls/>
                                <mesh position={[0, -0.25, 0]}
                                      ref={mesh}
                                      material={materials}
                         
                                >
                                    <boxGeometry args={[w, w * aspect, 0.05]}/>
                                </mesh>
                                <ambientLight intensity={0.8 * Math.PI}/>
                                <Environment preset="lobby" />



                            </Canvas>
                        </Suspense>
                    </View>

Am I doing something wrong? I have been debugging this for 6-7 hours and couldn't find a solution, I found that this happens when there is three version mismatch but I don't have multiple three versions installed, is there a specific version needed for react-fiber?
Error is thrown at three.cjs (22974:21)

Suggested solution:

@fl1k fl1k added the bug Something isn't working label May 2, 2024
@fl1k
Copy link
Author

fl1k commented May 2, 2024

Adding Environment to the Canvas causes the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant