A powerful, dual-mode 3D editor combining a pure React 3D viewer with a GrapesJS-based visual page builder. This project demonstrates seamless integration between a robust React 3D environment and a drag-and-drop web builder.
- Original 3D Editor: A focused, full-screen 3D editing environment.
- GrapesJS Editor: A visual page builder (drag-and-drop) that embeds the 3D viewer as a customizable component.
- GLB Model Support: Upload and view standard
.glband.gltffiles. - Hotspot System: click directly on the 3D model to add interactive hotspots.
- Orbit Controls: Fully interactive camera with zoom, pan, and rotate.
- Auto-Fit Camera: improved logic that automatically centers and scales the camera to fit the loaded model, respecting user-defined scaling.
- Custom 3D Block: A dedicated "3D Model Viewer" block available in the GrapesJS block manager.
- Reactive Custom Traits: Configure model properties directly from the GrapesJS Settings panel:
- Model Source: File upload for GLB assets.
- Scale: Real-time resizing of the 3D model without distorting the camera view.
- Camera Preset: Quick toggle between Front, Side, and Top views.
- Background Color: Customizable canvas background.
- React-Renderer Plugin: A specialized plugin that bridges GrapesJS's HTML rendering with React's component lifecycle, allowing complex interactive components (like Three.js scenes) to live inside the visual builder.
- File Format: The application is optimized for
.glb(binary glTF) files. - Environment: Designed to run in a modern browser environment supporting WebGL.
- Development: The project assumes a standard Node.js development environment.
- Data Persistence: Currently, all data (uploaded models, hotspots) is stored in local component state or temporary Blob URLs. Refreshing the page will reset the application to its initial state.
- State Management: The "Original 3D Editor" and "GrapesJS Editor" currently maintain separate instances of the hotspot state. Hotspots created in one mode do not automatically persist to the other.
- Single Model: The 3D Viewer block is designed to display a single model. Adding multiple blocks will create independent viewer instances.
- Core: React 19, TypeScript
- Build Tool: Vite
- 3D Engine: Three.js, @react-three/fiber, @react-three/drei
- Page Builder: GrapesJS, @grapesjs/react
- Styling: TailwindCSS 4
- UI Components: Shadcn UI
-
Clone the repository:
git clone https://github.com/Arkorede/swiftxr-mini-editorr.git cd swiftxr-mini-editorr -
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open the application: Navigate to
http://localhost:5173(or the port shown in your terminal).
By default, you start in the GrapesJS Editor mode.
- Add a 3D Viewer: Open the "Blocks" panel (left sidebar) and drag the "3D Model Viewer" block onto the canvas.
- Add text and section: Open the "Blocks" panel (left sidebar) and drag the "Text" and "Section" blocks onto the canvas.
- Configure: Select the component on the canvas and open the "Settings" panel (gear icon, right sidebar).
- Upload: Click the file input to upload a
.glbfile. - Adjust: Change the Scale, Background Color, or Camera Preset.
- Upload: Click the file input to upload a
- Switch Modes: Click the "Switch to Original 3D Editor" button in the top-left corner to enter the standalone 3D mode.
This mode focuses entirely on the model.
- Upload: Use the panel on the left to upload a model if one isn't already loaded.
- Hotspots: Click anywhere on the 3D model to place a hotspot. You can label these hotspots for interactive annotations.
- Switch Back: Click "Switch to GrapesJS Editor" to return to the page builder.
src/components/Editor3D.tsx: The core React Three Fiber scene. Handles models, lights, and camera logic.src/components/GrapesJSEditor.tsx: The main GrapesJS shell. Configures the editor, panels, and plugins.src/components/grapesjs-3d-viewer-component.ts: Defines the custom GrapesJS block and its traits (settings).src/components/react-renderer-plugin.ts: The bridge that mounts React components into the GrapesJS canvas.src/components/ThreeJSViewerWrapper.tsx: The adapter component that receives props from GrapesJS and renders theEditor3Dcomponent.