Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaa committed Mar 30, 2024
1 parent b9d714f commit 8dbe001
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions HandsRuler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
160ED7982B4B74C5002AD987 /* 🧑HeadTrackingSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 160ED7972B4B74C5002AD987 /* 🧑HeadTrackingSystem.swift */; };
16159B8A2BB7D82C00106FD6 /* 🪧ResultModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16159B892BB7D82C00106FD6 /* 🪧ResultModel.swift */; };
16159B8C2BB7E31C00106FD6 /* 📢Sounds.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16159B8B2BB7E31B00106FD6 /* 📢Sounds.swift */; };
16253CFB2B4E2FCB0028F0E2 /* 📏Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16253CFA2B4E2FCB0028F0E2 /* 📏Unit.swift */; };
16267B502B57D172000CA8AD /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 16267B4F2B57D172000CA8AD /* Localizable.xcstrings */; };
16267B522B57D362000CA8AD /* InfoPlist.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 16267B512B57D362000CA8AD /* InfoPlist.xcstrings */; };
Expand Down Expand Up @@ -86,6 +87,7 @@
160F46BB2B5A57AF001FE696 /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
160F46BC2B5A57D4001FE696 /* appstore_badge.svg */ = {isa = PBXFileReference; lastKnownFileType = text; path = appstore_badge.svg; sourceTree = "<group>"; };
16159B892BB7D82C00106FD6 /* 🪧ResultModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "🪧ResultModel.swift"; sourceTree = "<group>"; };
16159B8B2BB7E31B00106FD6 /* 📢Sounds.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "📢Sounds.swift"; sourceTree = "<group>"; };
16253CFA2B4E2FCB0028F0E2 /* 📏Unit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "📏Unit.swift"; sourceTree = "<group>"; };
16267B4F2B57D172000CA8AD /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
16267B512B57D362000CA8AD /* InfoPlist.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = InfoPlist.xcstrings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -154,6 +156,7 @@
children = (
16253CFA2B4E2FCB0028F0E2 /* 📏Unit.swift */,
16159B892BB7D82C00106FD6 /* 🪧ResultModel.swift */,
16159B8B2BB7E31B00106FD6 /* 📢Sounds.swift */,
16C4C6AA2BB7B17C004DB77E /* 💾Log */,
);
path = Rest;
Expand Down Expand Up @@ -388,6 +391,7 @@
16891ED92B7B2F8D00C6F0B3 /* 🗒️StaticInfo.swift in Sources */,
16C4C6A52BB78A06004DB77E /* 🌐SpaceModel.swift in Sources */,
16891EDA2B7B2F8D00C6F0B3 /* ℹ️AboutApp.swift in Sources */,
16159B8C2BB7E31C00106FD6 /* 📢Sounds.swift in Sources */,
165ADB4F2B4B71B0008A756F /* App.swift in Sources */,
16C4C6A92BB7AF0B004DB77E /* 🛠️AboutMenu.swift in Sources */,
16359E262B91D6AC004CC792 /* 🧑HeadTrackingComponent.swift in Sources */,
Expand Down
9 changes: 9 additions & 0 deletions HandsRuler/Rest/📢Sounds.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import RealityKit

struct 📢Sounds {
private let sound1: AudioFileResource = try! .load(named: "sound1")
private let sound2: AudioFileResource = try! .load(named: "sound2")
subscript(selected: Bool) -> AudioFileResource {
selected ? self.sound1 : self.sound2
}
}
7 changes: 3 additions & 4 deletions HandsRuler/🌐SpaceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class 🌐SpaceModel: ObservableObject {
private let lineEntity = 🧩Entity.line()
private let fingerEntities: [HandAnchor.Chirality: Entity] = 🧩Entity.fingerTips()

private let sound1: AudioFileResource = try! .load(named: "sound1")
private let sound2: AudioFileResource = try! .load(named: "sound2")
private let sounds: 📢Sounds = .init()
}

extension 🌐SpaceModel {
Expand Down Expand Up @@ -51,13 +50,13 @@ extension 🌐SpaceModel {
case 🧩Name.fingerLeft:
self.selectedLeft.toggle()
self.fingerEntities[.left]?.components.set(🧩Model.fingerTip(self.selectedLeft))
let player = targetedEntity.prepareAudio(self.selectedLeft ? self.sound1 : self.sound2)
let player = targetedEntity.prepareAudio(self.sounds[self.selectedLeft])
player.gain = -8
player.play()
case 🧩Name.fingerRight:
self.selectedRight.toggle()
self.fingerEntities[.right]?.components.set(🧩Model.fingerTip(self.selectedRight))
let player = targetedEntity.prepareAudio(self.selectedRight ? self.sound1 : self.sound2)
let player = targetedEntity.prepareAudio(self.sounds[self.selectedRight])
player.gain = -8
player.play()
default:
Expand Down
10 changes: 6 additions & 4 deletions HandsRuler/🌐SpaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ struct 🌐SpaceView: View {
self.model.setUp_simulator()
} update: { _, attachments in
self.model.logs.elements.forEach { log in
let fixedResultEntity = attachments.entity(for: "\(log.id)")!
fixedResultEntity.components.set(🧑HeadTrackingComponent())
fixedResultEntity.name = "\(log.id)"
self.model.rootEntity.addChild(fixedResultEntity)
if self.model.rootEntity.findEntity(named: "\(log.id)") == nil {
let fixedResultEntity = attachments.entity(for: "\(log.id)")!
fixedResultEntity.components.set(🧑HeadTrackingComponent())
fixedResultEntity.name = "\(log.id)"
self.model.rootEntity.addChild(fixedResultEntity)
}
}
} attachments: {
Attachment(id: "result") {
Expand Down

0 comments on commit 8dbe001

Please sign in to comment.