Read more...
asked 2 hour ago
1
13
I am working on a 3D interactive menu for a restaurant and I want to use Three.js inside the Next.js 15 App Router.
My main challenges are:
react-three-fiber or stick with vanilla Three.js for better control in a Next.js environment?2
0
To build a high-performance 3D interactive restaurant menu or any complex WebGL scene, you should focus on these three pillars:
Canvas PersistenceWhile vanilla Three.js is powerful, React Three Fiber is the standard for Next.js. To prevent the scene from unmounting or re-rendering during route changes:
Canvas in a Persistent Layout (e.g., template.tsx or a global layout.tsx).Loading heavy models can freeze the UI. Use these techniques:
useGLTF with Suspense: Leverage React Suspense to show a 2D loading placeholder while the 3D assets are being fetched..glb models using Draco. It significantly reduces file size (often by 70-90%).useGLTF.preload('/model.glb') in your main entry point to start downloading the assets before the user even navigates to the 3D section.next/dynamic: Import your 3D components using dynamic(() => import('./Scene'), { ssr: false }). This ensures that heavy WebGL code is only loaded on the client side.frameloop="demand" in your <Canvas> to only render frames when a change occurs, saving battery and CPU.0
0