Requirements
- A browser app that uses a bundler, such as Vite.
- Three.js
0.168. Floorkit makes Three.js objects and your app shows them. - TypeScript is optional. The package includes its type declarations.
Install the package
1
Add Floorkit and its peer packages
opengeometry is the geometry kernel. Floorkit installs it as a dependency. Install it directly too, because the next step imports its WebAssembly file.2
Start the geometry kernel
The kernel is a WebAssembly file. Give its address to Floorkit one time, when your app starts. With Vite, the Wait for this call to finish before you create geometry.
?url import gives you the address.3
Add the Vite types
TypeScript must know the
?url import. A new Vite app knows it already: its tsconfig.json has "types": ["vite/client"]. If yours does not, put this line in src/vite-env.d.ts:Use one copy of Three.js
The text package currently depends on a different Three.js version. Tell npm to use your app’s version everywhere. Add this field to your app’spackage.json, then run the install commands above:
npm ls three should show one version. If you installed before adding the override, follow Troubleshooting.
Use a different bundler
Floorkit needs only the address ofopengeometry_bg.wasm. Each bundler that can copy a file and give you its address works. You can also copy the file into your public folder and pass its path as text.
Import from one place
All classes, functions and types come from the package root:Next steps
Quickstart
Show a room with a door and a window.
Troubleshooting
Fix an install or a start-up problem.