From 70a60ee639dcb7f1fd9d21c8f5411c5778b8e13d Mon Sep 17 00:00:00 2001 From: Percen <21pesi1bif@hft-stuttgart.de> Date: Sat, 14 Dec 2024 15:00:57 +0000 Subject: [PATCH] Update public/index.html --- public/index.html | 420 ++++++++++++++++++++++++++++------------------ 1 file changed, 260 insertions(+), 160 deletions(-) diff --git a/public/index.html b/public/index.html index feb479d..f32aeab 100644 --- a/public/index.html +++ b/public/index.html @@ -1,168 +1,268 @@ - + + - - - GeoVis AR Projekt - - - + + + 3D Modell Umschalter - Sonnenblume und Roboter + + - + + + + + + + + function onWindowResize() { + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + renderer.setSize(window.innerWidth, window.innerHeight); + } + + function loop() { + ThreeMeshUI.update(); + controls.update(); + renderer.render(scene, camera); + updateButtons(); + } + + function updateButtons() { + let intersect; + + if (mouse.x !== null && mouse.y !== null) { + raycaster.setFromCamera(mouse, camera); + intersect = raycast(); + } + + if (intersect && intersect.object.isUI) { + if (selectState) { + intersect.object.setState('selected'); + } else { + intersect.object.setState('hovered'); + } + } + + objsToTest.forEach((obj) => { + if ((!intersect || obj !== intersect.object) && obj.isUI) { + obj.setState('idle'); + } + }); + } + + function raycast() { + return objsToTest.reduce((closestIntersection, obj) => { + const intersection = raycaster.intersectObject(obj, true); + if (!intersection[0]) return closestIntersection; + if (!closestIntersection || intersection[0].distance < closestIntersection.distance) { + intersection[0].object = obj; + return intersection[0]; + } + return closestIntersection; + }, null); + } + + -- GitLab