Swiftpack.co -  maxxfrazer/FocusEntity as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
maxxfrazer/FocusEntity
Bringing the scanning box from SceneKit to RealityKit
.package(url: "https://github.com/maxxfrazer/FocusEntity.git", from: "v2.2.3")

FocusEntity

This package is based on the package ARKit-FocusNode, but adapted to work in Apple's framework RealityKit.

FocusEntity Example 1

The Example looks identical to the above GIF, which uses the FocusEntity classic style.

Minimum Requirements

  • Swift 5.2
  • iOS 13.0 (RealityKit)
  • Xcode 11

If you're unfamiliar with using RealityKit, I would also recommend reading my articles on Getting Started with RealityKit.

Installation

Swift Package Manager

Add the URL of this repository to your Xcode 11+ Project.

Go to File > Swift Packages > Add Package Dependency, and paste in this link: https://github.com/maxxfrazer/FocusEntity


Usage

See the 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 FocusEntity:
    let focusSquare = FocusEntity(on: self.arView, style: .classic)

    (Optional)
  • Set focusSquare.delegate to an object which conforms to FocusEntityDelegate if you wish to get callbacks for when the FocusEntity changes state.
  • Optionally, you may select to use one of 3 visual styles: classic, color, and material.
  • If you choose material, you may use the preset textures or provide your own customized textures.
  • If you want to provide your own textures, add them to the Assets.xcassets catalog, then type the name of the asset in the appropriate place in this code:
    let onColor: MaterialColorParameter = try .texture(.load(named: "<#customAsset1#>"))
    let offColor: MaterialColorParameter = try .texture(.load(named: "<#customAsset2#>"))

If something's not making sense in the Example, send me a tweet 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.


The original code to create this repository has been adapted from one of Apple's examples from 2018, license also included. I have merely adapted the code to be used and distributed from within a Swift Package, and now further adapted to work with RealityKit.

GitHub

link
Stars: 103
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Patch Fix
4 weeks ago

Fix setAutoUpdate method.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API