Files
Gas-Tank-AR-App/GasTankAR/Model/ProjectPhoto.swift
Dennis Nemec b8536d4182 Add tank catalog with USDZ models and tank selection
Introduce TankDefinition/TankCatalog loaded from Tanks.json, bundle the
Drachengas USDZ tank models, add tank selection and preview views, and
update the AR experience, editor and project views to use the catalog.
Includes tests for catalog loading and model selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 19:12:39 +02:00

60 lines
2.0 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ProjectPhoto.swift
// GasTankAR
//
// Created by Dennis Nemec on 27.08.26.
//
import Foundation
import SwiftData
import CoreLocation
/// Ein im AR-Modus aufgenommenes Foto (Snapshot der Kamera-Sicht), das zu einem Projekt gehört.
/// Die Bilddaten liegen wegen ihrer Größe extern (`.externalStorage`).
@Model
final class ProjectPhoto {
/// Aufnahmezeitpunkt – Grundlage für die Gruppierung in der Galerie.
var creationDate: Date
/// Aktuelle Bilddaten. Nach einer Bearbeitung enthält diese Property die gerenderte PNG-Datei.
@Attribute(.externalStorage) var imageData: Data
/// Unveränderte Originaldaten für die Funktion „Zeichnung zurücksetzen“.
@Attribute(.externalStorage) var originalImageData: Data?
/// Gespeicherte Version des Fotos mit Zeichnung.
@Attribute(.externalStorage) var annotatedImageData: Data?
/// Geografische Breite des Aufnahmeorts, sofern beim Aufnehmen ein Standort vorlag.
var latitude: Double?
/// Geografische Länge des Aufnahmeorts, sofern beim Aufnehmen ein Standort vorlag.
var longitude: Double?
/// Zugehöriges Projekt (Rückbeziehung zu `Project.photos`).
var project: Project?
init(
creationDate: Date,
imageData: Data,
originalImageData: Data? = nil,
annotatedImageData: Data? = nil,
latitude: Double? = nil,
longitude: Double? = nil,
project: Project? = nil
) {
self.creationDate = creationDate
self.imageData = imageData
self.originalImageData = originalImageData
self.annotatedImageData = annotatedImageData
self.latitude = latitude
self.longitude = longitude
self.project = project
}
/// Aufnahmeort als Koordinate – `nil`, wenn kein Standort gespeichert wurde.
var coordinate: CLLocationCoordinate2D? {
guard let latitude, let longitude else { return nil }
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}
}