From e96d57531279066a55b3f3e676f0588bb7b287c4 Mon Sep 17 00:00:00 2001 From: Thomas Fuhrmann Date: Thu, 20 Mar 2025 11:44:50 +0100 Subject: [PATCH] Add compass --- app/components/Form.tsx | 178 ++++++++++++++++----------------- app/page.tsx | 12 +-- app/three/utils/build-scene.ts | 13 ++- 3 files changed, 101 insertions(+), 102 deletions(-) diff --git a/app/components/Form.tsx b/app/components/Form.tsx index 2a89a9b..217e1ff 100644 --- a/app/components/Form.tsx +++ b/app/components/Form.tsx @@ -83,13 +83,11 @@ const Accordion = forwardRef( return (
-

+

@@ -210,96 +208,94 @@ export function Form() { } return ( -
-
-
- -
-
- - - - - -
-
- -
+
+
+ +
+
+ + + + + +
+
+ +
-
- - { -
- {sceneView?.model.children.map((child) => { - const key = `toggle-visibility-${child.name}`; - const color = `#${( - (child as Mesh).material as MeshStandardMaterial - ).color.getHexString()}`; - const visible = (child as Mesh).visible; +
+ + { +
+ {sceneView?.model.children.map((child) => { + const key = `toggle-visibility-${child.name}`; + const color = `#${( + (child as Mesh).material as MeshStandardMaterial + ).color.getHexString()}`; + const visible = (child as Mesh).visible; - return ( -
+ + handleCheckboxChange(child.name)} + className="hover:cursor-pointer" + defaultChecked={visible ? true : false} + /> +
- ); - })} -
- } -
- - {emptyProfile ? ( -
- Virtual profile does not intersect the model. -
- ) : null} -
-
- Please enable the Virtual Profile toggle and select a profile - position! -
+ {child.name} + +
+ ); + })}
- -
+ } +
+ + {emptyProfile ? ( +
+ Virtual profile does not intersect the model. +
+ ) : null} +
+
+ Please enable the Virtual Profile toggle and select a profile + position! +
+
+
); diff --git a/app/page.tsx b/app/page.tsx index 85895fb..6e89581 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -10,9 +10,9 @@ export default function Home() { const [isFormOpen, setIsFormOpen] = useState(false); return ( -
-
- +
+ +
3D-Viewer @@ -45,8 +45,8 @@ export default function Home() {
-
-
-
+
+ + ); } diff --git a/app/three/utils/build-scene.ts b/app/three/utils/build-scene.ts index 505ad5e..e4872fc 100644 --- a/app/three/utils/build-scene.ts +++ b/app/three/utils/build-scene.ts @@ -93,12 +93,12 @@ export function buildScene(container: HTMLElement, extent: Extent) { // Create the AxesHelper (small size) axesHelper = new AxesHelper(0.1); - axesHelper.position.set(-0.9, -0.8, 0); + axesHelper.position.set(-0.85, -0.85, 0); const xLabel = createTextSprite("X", "red"); const yLabel = createTextSprite("Y", "green"); const zLabel = createTextSprite("Z", "blue"); - xLabel.position.set(0.125, 0, 0); + xLabel.position.set(0.125, -0.01, 0); yLabel.position.set(0, 0.125, 0); zLabel.position.set(0, 0, 0.125); @@ -120,16 +120,19 @@ function onWindowResize(container: HTMLElement) { } function animate() { - // axesHelper.quaternion.copy(camera.quaternion); + // Set rotation of axes according to camera rotation let rot = new Euler(); rot.x = -camera.rotation.x; rot.y = camera.rotation.y; - rot.z = camera.rotation.z; + rot.z = -camera.rotation.z; axesHelper.setRotationFromEuler(rot); + renderer.autoClear = true; renderer.render(scene, camera); + + // Set autoclear to fasle in order to overlay UI elements renderer.autoClear = false; - renderer.render(uiScene, uiCamera); // Render UI scene + renderer.render(uiScene, uiCamera); // required if controls.enableDamping or controls.autoRotate are set to true controls.update();