diff --git a/app/components/Form.tsx b/app/components/Form.tsx index afccef3..7e34aa2 100644 --- a/app/components/Form.tsx +++ b/app/components/Form.tsx @@ -36,7 +36,7 @@ function Toggle({ defaultChecked={defaultChecked ? true : false} />
- + {title} @@ -191,9 +191,23 @@ export function Form() { } } + function handleExport() { + if (!sceneView) return; + + sceneView.exportOBJ(); + } + return (
-
+
+
+ +
diff --git a/app/components/Map.tsx b/app/components/Map.tsx index 06bb451..493ba77 100644 --- a/app/components/Map.tsx +++ b/app/components/Map.tsx @@ -39,7 +39,7 @@ export function Map() { }, [divRef, setSceneView]); return ( -
+
); diff --git a/app/page.tsx b/app/page.tsx index 67e2e88..eebee00 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,18 +1,42 @@ +"use client"; + import { Map } from "./components/Map"; import { Form } from "./components/Form"; import { SceneViewProvider } from "./providers/scene-view-provider"; +import { useState } from "react"; export default function Home() { + const [isFormOpen, setIsFormOpen] = useState(false); + return (
-
+
-
+
+ 3D-Viewer + +
+
-
-
+
+ +
diff --git a/app/three/SceneView.ts b/app/three/SceneView.ts index 66fe55f..24e6421 100644 --- a/app/three/SceneView.ts +++ b/app/three/SceneView.ts @@ -20,7 +20,7 @@ import { buildClippingplanes, } from "./utils/build-clipping-planes"; import { buildCoordinateGrid } from "./utils/build-coordinate-grid"; -import { DragControls } from "three/examples/jsm/Addons.js"; +import { DragControls, OBJExporter } from "three/examples/jsm/Addons.js"; import { MapTilerProvider, MapView, OpenStreetMapsProvider } from "geo-three"; import { CustomMapHeightNodeShader } from "./CustomMapHeightNodeShader"; import { Data, createSVG } from "./utils/create-borehole-svg"; @@ -286,6 +286,21 @@ export class SceneView extends EventTarget { this._scene.remove(o); } } + + // Function to export the group as an OBJ file + public exportOBJ() { + const exporter = new OBJExporter(); + const objString = exporter.parse(this._model); + + // Create a Blob and trigger a download + const blob = new Blob([objString], { type: "text/plain" }); + const link = document.createElement("a"); + link.href = URL.createObjectURL(blob); + link.download = "geologic_model.obj"; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } } async function init(container: HTMLElement, modelId = MODEL_ID) {