Skip to content

Commit

Permalink
Merge pull request #9 from maxxfrazer/raycast
Browse files Browse the repository at this point in the history
2.0 Update

- Just one class with multiple styles
- No more dependency on SmartHitTest.
- Using Raycast instead of hitTesting
- Methods for destroying added
- Methods for moving between ARViews
  • Loading branch information
maxxfrazer authored Jun 28, 2020
2 parents b5bf4fe + 7137da8 commit 352836f
Show file tree
Hide file tree
Showing 13 changed files with 586 additions and 652 deletions.
65 changes: 25 additions & 40 deletions FocusEntity-Example/FocusEntity-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -13,12 +13,13 @@
F301E0DA231462AB0028AAF1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F301E0D9231462AB0028AAF1 /* Preview Assets.xcassets */; };
F301E0DD231462AB0028AAF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F301E0DB231462AB0028AAF1 /* LaunchScreen.storyboard */; };
F301E0E5231462D90028AAF1 /* FocusARView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F301E0E4231462D90028AAF1 /* FocusARView.swift */; };
F301E0F7231515730028AAF1 /* SmartHitTest in Frameworks */ = {isa = PBXBuildFile; productRef = F301E0F6231515730028AAF1 /* SmartHitTest */; };
F3F29EE02317C0DA00C3864B /* FESquare.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDB2317C0DA00C3864B /* FESquare.swift */; };
F3F29EE12317C0DA00C3864B /* FESquare+Segment.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDC2317C0DA00C3864B /* FESquare+Segment.swift */; };
F3D758E424992EAC0019A821 /* FocusEntity+Alignment.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D758E324992EAC0019A821 /* FocusEntity+Alignment.swift */; };
F3D758E6249930080019A821 /* FocusEntityComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D758E5249930080019A821 /* FocusEntityComponent.swift */; };
F3F29EE02317C0DA00C3864B /* FocusEntity+Classic.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDB2317C0DA00C3864B /* FocusEntity+Classic.swift */; };
F3F29EE12317C0DA00C3864B /* FocusEntity+Segment.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDC2317C0DA00C3864B /* FocusEntity+Segment.swift */; };
F3F29EE22317C0DA00C3864B /* float4x4+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDD2317C0DA00C3864B /* float4x4+Extension.swift */; };
F3F29EE32317C0DA00C3864B /* FocusEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDE2317C0DA00C3864B /* FocusEntity.swift */; };
F3F29EE42317C0DA00C3864B /* FEPlane.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDF2317C0DA00C3864B /* FEPlane.swift */; };
F3F29EE42317C0DA00C3864B /* FocusEntity+Colored.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDF2317C0DA00C3864B /* FocusEntity+Colored.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -30,19 +31,20 @@
F301E0DC231462AB0028AAF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
F301E0DE231462AB0028AAF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F301E0E4231462D90028AAF1 /* FocusARView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FocusARView.swift; sourceTree = "<group>"; };
F3F29EDB2317C0DA00C3864B /* FESquare.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FESquare.swift; sourceTree = "<group>"; };
F3F29EDC2317C0DA00C3864B /* FESquare+Segment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "FESquare+Segment.swift"; path = "../../Sources/FocusEntity/FESquare+Segment.swift"; sourceTree = "<group>"; };
F3D758E324992EAC0019A821 /* FocusEntity+Alignment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Alignment.swift"; sourceTree = "<group>"; };
F3D758E5249930080019A821 /* FocusEntityComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FocusEntityComponent.swift; sourceTree = "<group>"; };
F3F29EDB2317C0DA00C3864B /* FocusEntity+Classic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Classic.swift"; sourceTree = "<group>"; };
F3F29EDC2317C0DA00C3864B /* FocusEntity+Segment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Segment.swift"; sourceTree = "<group>"; };
F3F29EDD2317C0DA00C3864B /* float4x4+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "float4x4+Extension.swift"; path = "../../Sources/FocusEntity/float4x4+Extension.swift"; sourceTree = "<group>"; };
F3F29EDE2317C0DA00C3864B /* FocusEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FocusEntity.swift; path = ../../Sources/FocusEntity/FocusEntity.swift; sourceTree = "<group>"; };
F3F29EDF2317C0DA00C3864B /* FEPlane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FEPlane.swift; sourceTree = "<group>"; };
F3F29EDF2317C0DA00C3864B /* FocusEntity+Colored.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Colored.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
F301E0CA231462A90028AAF1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F301E0F7231515730028AAF1 /* SmartHitTest in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -91,11 +93,13 @@
F301E0EE231515370028AAF1 /* FocusEntity */ = {
isa = PBXGroup;
children = (
F3F29EDF2317C0DA00C3864B /* FEPlane.swift */,
F3F29EDB2317C0DA00C3864B /* FESquare.swift */,
F3F29EDC2317C0DA00C3864B /* FESquare+Segment.swift */,
F3F29EDF2317C0DA00C3864B /* FocusEntity+Colored.swift */,
F3F29EDB2317C0DA00C3864B /* FocusEntity+Classic.swift */,
F3F29EDC2317C0DA00C3864B /* FocusEntity+Segment.swift */,
F3D758E5249930080019A821 /* FocusEntityComponent.swift */,
F3F29EDD2317C0DA00C3864B /* float4x4+Extension.swift */,
F3F29EDE2317C0DA00C3864B /* FocusEntity.swift */,
F3D758E324992EAC0019A821 /* FocusEntity+Alignment.swift */,
);
name = FocusEntity;
path = ../Sources/FocusEntity;
Expand All @@ -118,7 +122,6 @@
);
name = "FocusEntity-Example";
packageProductDependencies = (
F301E0F6231515730028AAF1 /* SmartHitTest */,
);
productName = "FocusEntity-Example";
productReference = F301E0CD231462A90028AAF1 /* FocusEntity-Example.app */;
Expand Down Expand Up @@ -149,7 +152,6 @@
);
mainGroup = F301E0C4231462A90028AAF1;
packageReferences = (
F301E0F5231515730028AAF1 /* XCRemoteSwiftPackageReference "ARKit-SmartHitTest" */,
);
productRefGroup = F301E0CE231462A90028AAF1 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -178,14 +180,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F3D758E424992EAC0019A821 /* FocusEntity+Alignment.swift in Sources */,
F3F29EE32317C0DA00C3864B /* FocusEntity.swift in Sources */,
F301E0D3231462A90028AAF1 /* ContentView.swift in Sources */,
F3F29EE02317C0DA00C3864B /* FESquare.swift in Sources */,
F3F29EE42317C0DA00C3864B /* FEPlane.swift in Sources */,
F3F29EE02317C0DA00C3864B /* FocusEntity+Classic.swift in Sources */,
F3F29EE42317C0DA00C3864B /* FocusEntity+Colored.swift in Sources */,
F301E0D1231462A90028AAF1 /* AppDelegate.swift in Sources */,
F3F29EE22317C0DA00C3864B /* float4x4+Extension.swift in Sources */,
F3F29EE12317C0DA00C3864B /* FESquare+Segment.swift in Sources */,
F3F29EE12317C0DA00C3864B /* FocusEntity+Segment.swift in Sources */,
F301E0E5231462D90028AAF1 /* FocusARView.swift in Sources */,
F3D758E6249930080019A821 /* FocusEntityComponent.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -323,14 +327,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"FocusEntity-Example/Preview Content\"";
DEVELOPMENT_TEAM = N2RTJDRM64;
DEVELOPMENT_TEAM = 278494H572;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "FocusEntity-Example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "cobb.max.FocusEntity-Example";
PRODUCT_BUNDLE_IDENTIFIER = "uk.rocketar.FocusEntity-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -343,14 +347,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"FocusEntity-Example/Preview Content\"";
DEVELOPMENT_TEAM = N2RTJDRM64;
DEVELOPMENT_TEAM = 278494H572;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "FocusEntity-Example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "cobb.max.FocusEntity-Example";
PRODUCT_BUNDLE_IDENTIFIER = "uk.rocketar.FocusEntity-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -379,25 +383,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
F301E0F5231515730028AAF1 /* XCRemoteSwiftPackageReference "ARKit-SmartHitTest" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/maxxfrazer/ARKit-SmartHitTest";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
F301E0F6231515730028AAF1 /* SmartHitTest */ = {
isa = XCSwiftPackageProductDependency;
package = F301E0F5231515730028AAF1 /* XCRemoteSwiftPackageReference "ARKit-SmartHitTest" */;
productName = SmartHitTest;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = F301E0C5231462A90028AAF1 /* Project object */;
}
8 changes: 3 additions & 5 deletions FocusEntity-Example/FocusEntity-Example/FocusARView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import ARKit
import UIKit

class FocusARView: ARView {
let focusSquare = FESquare()
var focusEntity: FocusEntity?
required init(frame frameRect: CGRect) {
super.init(frame: frameRect)
focusSquare.viewDelegate = self
focusSquare.delegate = self
focusSquare.setAutoUpdate(to: true)
self.setupConfig()
self.focusEntity = FocusEntity(on: self, style: .classic)
}

func setupConfig() {
Expand All @@ -33,7 +31,7 @@ class FocusARView: ARView {
}
}

extension FocusARView: FEDelegate {
extension FocusARView: FocusEntityDelegate {
func toTrackingState() {
print("tracking")
}
Expand Down
10 changes: 2 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ let package = Package(
products: [
.library(name: "FocusEntity", targets: ["FocusEntity"])
],
dependencies: [
// .package(path: "../ARKit-SmartHitTest")
.package(
url: "https://github.com/maxxfrazer/ARKit-SmartHitTest",
.upToNextMajor(from: "2.0.0")
)
],
dependencies: [],
targets: [
.target(name: "FocusEntity", dependencies: ["SmartHitTest"])
.target(name: "FocusEntity", dependencies: [])
],
swiftLanguageVersions: [.v5]
)
39 changes: 16 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
# FocusEntity

This package is based on the package [ARKit-FocusNode](https://github.com/maxxfrazer/ARKit-FocusNode), but adapted to work in Apple's Augmented Reality framework, RealityKit.
This package is based on the package [ARKit-FocusNode](https://github.com/maxxfrazer/ARKit-FocusNode), but adapted to work in Apple's framework RealityKit.

[![Lint Status](https://github.com/maxxfrazer/FocusEntity/workflows/swiftlint/badge.svg)](https://github.com/maxxfrazer/FocusEntity/actions)
[![Build Status](https://github.com/maxxfrazer/FocusEntity/workflows/build/badge.svg)](https://github.com/maxxfrazer/FocusEntity/actions)
[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-v1.1.0-orange.svg?style=flat)](https://github.com/apple/swift-package-manager)
[![Swift 5.0](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)](https://swift.org/)

![FocusEntity Example 1](media/FocusEntity-Example1.gif)

[The Example](./Example-RealityKit) looks identical to the above GIF, which uses the FESquare class (Focus Entity Square).


## ⚠️ iOS 13.2 bug ⚠️
<p align="center">
<img src="https://img.shields.io/badge/platform-iOS-lightgrey"/>
<img src="https://img.shields.io/github/v/release/maxxfrazer/FocusEntity?color=orange&label=SwiftPM&logo=swift"/>
<img src="https://img.shields.io/badge/Swift-5.2-orange?logo=swift"/>
<img src="https://github.com/maxxfrazer/FocusEntity/workflows/swiftlint/badge.svg"/>
<img src="https://github.com/maxxfrazer/FocusEntity/workflows/build/badge.svg"/>
<img src="https://img.shields.io/github/license/maxxfrazer/FocusEntity"/>
</p>

There is a crashing bug when using this library with iOS 13.2 and importing via Swift Package Manager

The Swift bug has been reported here:
https://bugs.swift.org/browse/SR-11564
![FocusEntity Example 1](media/FocusEntity-Example1.gif)

And there is a temporary solution, which involves setting the "Dead Code Stripping" property in your build's target to "No"
[The Example](./Example-RealityKit) looks identical to the above GIF, which uses the FocusEntity classic style.

Target > Build Settings > Linking > Dead Code Stripping

## Minimum Requirements
- Swift 5.0
- Swift 5.2
- iOS 13.0 (RealityKit)
- Xcode 11

Expand All @@ -44,17 +38,16 @@ Add the URL of this repository to your Xcode 11+ Project.
See the [Example](./FocusEntity-Example) for a full working example as can be seen in the GIF above

- After installing, import `FocusEntity` to your .swift file
- Create an instance of `let focusSquare = FESquare()`, or another `FocusEntity` class.
- Set `focusSquare.viewDelegate` to the `ARView` it is to be rendered within.
- Set the FocusEntity to auto-update: `focusSquare.setAutoUpdate(to: true)`
- Create an instance of FocusEntity:
<br>```let focusSquare = FocusEntity(on: self.arView, style: .classic)```
<br><br>(Optional)<br>
- Set `focusSquare.delegate` to an object which conforms to `FocusEntityDelegate` if you wish to get callbacks for when the FocusEntity changes state.


If something's not making sense in the Example, [send me a tweet](https://twitter.com/maxxfrazer) or Fork & open a Pull Request on this repository to make something more clear.

I'm hoping to make the animations look a little smoother over time, but any and all contributions are welcome and encouraged.

Please follow the guide for creating GitHub Issues, otherwise I may simply close them.

---

The original code to create this repository has been adapted from one of Apple's examples from 2018, [license also included](LICENSE.origin). I have merely adapted the code to be used and distributed from within a Swift Package, and now further adapted to work with [RealityKit](https://developer.apple.com/documentation/realitykit).
90 changes: 0 additions & 90 deletions Sources/FocusEntity/FEPlane.swift

This file was deleted.

Loading

0 comments on commit 352836f

Please sign in to comment.