Skip to content

Babylon.js + Next.js minimal working app

License

Notifications You must be signed in to change notification settings

sevaseva/babylonjs-nextjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A minimal one-page Next.js 13.x web app that uses Babylon.js 5.x to render a basic 3D scene.

git clone [URL] babylonjs-nextjs
cd babylonjs-nextjs
npm install
npm run dev

Then open the app at http://localhost:3000/

The lightweight page first loads completely (making the crawlers, bots and page speed analyzer tools happy) without fetching any Babylon.js code, heavy resources for the scene, without even the canvas element in the DOM. Then immediately (using React.js useState() trick that is explained in detail in index.js) re-renders - this time adding the BabylonScene react component to the page: that adds the canvas node to the DOM, loads Babylon.js related code to the client, executes out Babylon scene setup (which makes the resources such as texture images,GLBs, etc get downloaded to the client).

This is intended to demonstrate a resonable, clean way to render a Babylon.js scene in a Next.js app in the simplest possible way. Intentionally left out are nice things like pre-fetching, pre-loading, TypeScript, testing infrastructure, a recommended directory structure for a larger app, production/optimized build targets, demonstration of various useful Next.js, React.js features relevant for a WebGL heavy app, demonstration of useful libraries that aren't needed in this minimalist app.

For some of those things, consider reviewing

Languages

  • JavaScript 100.0%