Swiftpack.co - Reality-Dev/RealityKit-Asset-Loading as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Reality-Dev.
Reality-Dev/RealityKit-Asset-Loading 1.0.04
Enables easy, convenient asynchronous asset loading in RealityKit for many different kinds of assets.
⭐️ 2
🕓 2 weeks ago
.package(url: "https://github.com/Reality-Dev/RealityKit-Asset-Loading.git", from: "1.0.04")

RealityKit Asset Loading


This package includes classes and examples that enable easy, convenient asynchronous asset loading in RealityKit for all of these kinds of assets:

  • Entities
  • ModelEntities
  • BodyTrackedEntity
  • Audio
  • TextureResources
  • USDZ animations
  • Scenes from .reality files
  • Scenes from .rcproject files

It also includes some convenience methods for generating simple shapes (box, sphere and plane) with simple materials, such as ModelEntity.makeSphere().

For generating more simple shapes, see this package from Max Cobb:

For generating text, see this package:

There are different options provided: some for loading one file at a time, and others for loading many all together at once. You oftentimes have the option of either providing a URL specifying the location of the file on disk to load, or providing a file name and a bundle (bundle is optional - it defaults to the main bundle).

This package only includes asynchronous loading methods. Synchronous load operations block the thread on which you call them which can lead to the user interface stalling and the app becoming unresponsive, especially when loading complex scenes like is often done for AR experiences. To maintain a smooth user interface, it’s typically best to use an asynchronous load instead. All synchronous load operations have an asynchronous counterpart.

See these documentation articles for more information:


  • iOS 13 or macOS 10.15
  • Swift 5.2
  • Xcode 11


Swift Package Manager

Add the URL of this repository to your Xcode 11+ Project under: File > Add Packages https://github.com/Reality-Dev/RealityKit-Asset-Loading


Add import RKAssetLoading to the top of your swift file to start.


  • Your completion handlers should use a capture list such as [weak self] to avoid a memory leak from the completion closure capturing a strong reference to any objects. Here is an example of using this asset loader with a capture list:
    func loadOneModelEntity(){
        RKAssetLoader.loadModelEntityAsync(named: "gold_star"){[weak self] starModelEntity in
            starModelEntity.position = [0, 0, -2]

To learn more about automatic reference counting, strong reference cycles, and closure capture lists, see this link:

See the example project for multiple examples of how to load different kinds of assets:

The ARView file in the example project is especially helpful:


Stars: 2
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

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