From 9a50d4df15152b1ed0219de3e68aa9ce36762728 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 21 May 2026 08:33:53 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20Automatische=20Kameraanpassung=20f?= =?UTF-8?q?=C3=BCr=20bessere=20Modellansicht=20und=20Import=20von=20Hemisp?= =?UTF-8?q?h=C3=A4renlicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Character3D.vue | 18 ++++++++++++++++++ frontend/src/utils/threeRuntime.js | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/frontend/src/components/Character3D.vue b/frontend/src/components/Character3D.vue index e39b1e9..71edb66 100644 --- a/frontend/src/components/Character3D.vue +++ b/frontend/src/components/Character3D.vue @@ -401,6 +401,24 @@ export default { this.scene.add(this.model); + // Auto-Kamera-Anpassung: Abstand so setzen, dass die modell-Höhe gut ins Bild passt + try { + const scaledSize = scaledBox.getSize(new modelRuntime.Vector3()); + if (this.camera) { + const fovRad = (this.camera.fov * Math.PI) / 180; + const desiredHeight = Math.max(scaledSize.y, scaledSize.z) * 1.15; // etwas Margin + let distance = desiredHeight / (2 * Math.tan(fovRad / 2)); + if (!isFinite(distance) || distance <= 0) distance = 3; + const camY = scaledCenter.y + Math.max(0.5, scaledSize.y * 0.15); + const camZ = distance + 0.6; // kleiner Offset, damit etwas Raum vor dem Modell ist + this.camera.position.set(0, camY, camZ); + this.camera.lookAt(scaledCenter.x, scaledCenter.y, scaledCenter.z); + this.onWindowResize(); + } + } catch (e) { + // ignore camera auto-fit errors + } + // Animationen laden falls vorhanden if (gltf.animations && gltf.animations.length > 0) { this.mixer = markRaw(new modelRuntime.AnimationMixer(this.model)); diff --git a/frontend/src/utils/threeRuntime.js b/frontend/src/utils/threeRuntime.js index 81fd541..8ef2e29 100644 --- a/frontend/src/utils/threeRuntime.js +++ b/frontend/src/utils/threeRuntime.js @@ -2,18 +2,22 @@ import { PerspectiveCamera } from 'three/src/cameras/PerspectiveCamera.js'; import { Clock } from 'three/src/core/Clock.js'; import { AmbientLight } from 'three/src/lights/AmbientLight.js'; import { DirectionalLight } from 'three/src/lights/DirectionalLight.js'; +import { HemisphereLight } from 'three/src/lights/HemisphereLight.js'; import { Color } from 'three/src/math/Color.js'; import { TextureLoader } from 'three/src/loaders/TextureLoader.js'; import { WebGLRenderer } from 'three/src/renderers/WebGLRenderer.js'; import { Scene } from 'three/src/scenes/Scene.js'; +import { sRGBEncoding, ACESFilmicToneMapping } from 'three/src/constants.js'; export { AmbientLight, Clock, Color, DirectionalLight, + HemisphereLight, PerspectiveCamera, Scene, TextureLoader, WebGLRenderer + ,sRGBEncoding,ACESFilmicToneMapping };