Export2ThreeJS is a Unity script that allows you to convert Unity scenes from YAML format to Three.js JSON scenes.
- Export Scene in Unity:
- Right-click on any scene in the Unity Editor.
- Select TreeJS > Export2JSON from the context menu.
- A JSON file of the scene will be created in the
Build/folder at the root of your project.
- Go to the Three.js Editor.
- Drag and drop your exported JSON file into the editor to view and interact with your scene.
-
Create HTML File in Unity:
- In the Unity Editor, go to Tools > TreeJS > Create HTML. This will generate an HTML file in the
Build/folder, allowing you to easily view the exported scene.
- In the Unity Editor, go to Tools > TreeJS > Create HTML. This will generate an HTML file in the
-
Install Node.js: Ensure Node.js is installed on your system.
-
Set Up and Run the Server:
Open your terminal, navigate to the
Build/folder, and run the following commands:# Install Three.js npm install --save three # Install Vite (a fast frontend tool for web development) npm install --save-dev vite # Start the development server npx vite
-
If the server starts successfully, you'll see a URL like http://localhost:5173 in your terminal. Open this URL in your web browser.
-
Drag and drop your exported JSON file into the browser window to view and interact with your scene.