-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ReferenceError: window is not defined #271
Comments
@robylosa94 Thanks for this contribution. Could you please explain how you fixed it or add a reference to a resolved issue? |
I would like to know this as well. I'm running ThreeJS with NextJS and React |
@bastienrobert @19992077
Additionally found that dat.GUI does not work well with Fast Refresh, and doesn't know to not keep adding new menus, but thats another issue. |
To fix this issue, move const CanvasComponent = (props) => {
let gui;
const init = async () => {
const dat = await import('dat.gui')
if (!gui) {
gui = new dat.GUI()
// ... rest of the three.js code
}
}
useEffect(() => {
init()
}, [])
return (
<canvas id="webgl" />
)
} |
I'm working with nextjs and threejs.
My configuration is:
import * as dat from "dat.gui";
const gui= new dat.GUI();
gui.add(settings, "colorful");
gui.add(settings, "zoom");
gui.add(settings, "random");
The text was updated successfully, but these errors were encountered: