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

Console error: "MeshReflectorMaterial" is not part of the THREE namespace! #271

Closed
bfuhne opened this issue Jan 29, 2021 · 5 comments
Closed
Labels
bug Something isn't working released on @beta released in beta for review

Comments

@bfuhne
Copy link

bfuhne commented Jan 29, 2021

  • three version: 0.125.1
  • react-three-fiber version: 5.3.18
  • @react-three/drei version: 3.0.0-beta.6
  • node version: 14.13.0
  • npm (or yarn) version: 6.14.8

Problem description:

I downloaded the drei reflector demo, which is running fine as it is.

Then I run npm run-script build.
The build process finishes successfully.
But opening the build in the browser throws an error and the scene remains black:

"MeshReflectorMaterial" is not part of the THREE namespace! Did you forget to extend it?

How can I create a successful build?

@bfuhne bfuhne added the bug Something isn't working label Jan 29, 2021
@joshuaellis
Copy link
Member

Can you please provide an example of the code? Repo or Sandbox is fine.

@joshuaellis joshuaellis added the needs more info Needs more information before we can action something label Jan 29, 2021
@bfuhne
Copy link
Author

bfuhne commented Jan 29, 2021

Hi,

I downloaded the code from this sandbox:

https://codesandbox.io/s/drei-reflector-bfplr

And then ran npm install. Tested the demo using npm run-script start - is running fine.
Build via npm run-script build - Serving the build results in the above error.

@drcmda
Copy link
Member

drcmda commented Jan 29, 2021

@joshuaellis i think it should explicitely do

import '../materials/MeshReflectorMaterial'

in Reflector.tsx

the message above means that the extend wasn't executed for some reason. or at least by the time something tries to do

<meshReflectorMaterial/>

r3f had no known object for that. i think this is tree-shaking messing it up in production. it will remove MeshReflectorMaterial because it's never being used anywhere explicitely.

@joshuaellis joshuaellis added released on @beta released in beta for review and removed needs more info Needs more information before we can action something labels Jan 29, 2021
@joshuaellis
Copy link
Member

joshuaellis commented Jan 29, 2021

Hi @bfuhne,

Thanks for that. I've added a fix on beta - 3.1.0-beta.1 (im not sure why semantic-bot decided its 3.1). I've tested it and & it works for me, it'd be great if you can confirm too & i can merge to master for release.

cc @gsimone

@bfuhne
Copy link
Author

bfuhne commented Jan 29, 2021

Hi @joshuaellis,

can confirm, build version works beautifully with 3.1.0-beta.1.
I'm in awe of this level of help and support. Just amazing.

@bfuhne bfuhne closed this as completed Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released on @beta released in beta for review
Projects
None yet
Development

No branches or pull requests

3 participants