### Prepare and Configure Audio Playback Source: https://developer.apple.com/documentation/realitykit/entity/prepareaudio%28_%3A%29 Example showing how to prepare an audio resource and adjust playback properties before starting playback. ```swift let controller = entity.prepareAudio(anAudioResource) controller.gain = -10 // Apply a custom gain, if desired. controller.speed = 1.2 // Apply a custom speed, if desired. controller.play() ``` -------------------------------- ### Define a prepareWithDevice Callback Function Source: https://developer.apple.com/documentation/realitykit/arview/rendercallbacks-swift.struct/preparewithdevice Example of how to define a function that can be used as a prepareWithDevice callback. This function should contain your setup logic. ```swift func myPostProcessSetupCallback(device: MTLDevice) { // Handle setup work here. } ``` -------------------------------- ### Model3D Usage Example Source: https://developer.apple.com/documentation/realitykit/model3d/init%28from%3Aconfigurations%3Acontent%3Aplaceholder%3A%29 Example demonstrating how to use the Model3D initializer with a configuration catalog, specifying model configurations, and providing a content closure and a placeholder view. ```swift Model3D( from: myConfigurationCatalog, configurations: ["vibe": "relaxed"] ) { model in model.resizable() } placeholder: { Color.green } ``` -------------------------------- ### GET Scene.AnchorCollection.startIndex Source: https://developer.apple.com/documentation/realitykit/scene/anchorcollection/startindex Retrieves the starting index of the anchor collection. ```APIDOC ## GET Scene.AnchorCollection.startIndex ### Description The position of the first element in a nonempty collection. If the collection is empty, startIndex is equal to endIndex. ### Method GET ### Endpoint Scene.AnchorCollection.startIndex ### Response #### Success Response (200) - **startIndex** (Int) - The position of the first element in the collection. ``` -------------------------------- ### GET JointTransforms.startIndex Source: https://developer.apple.com/documentation/realitykit/jointtransforms/startindex Retrieves the starting index of the joint transform collection. ```APIDOC ## GET JointTransforms.startIndex ### Description Returns an index to the first joint transform in the collection. ### Property `var startIndex: JointTransforms.Index { get }` ### Availability - iOS 15.0+ - iPadOS 15.0+ - Mac Catalyst 15.0+ - macOS 12.0+ - tvOS 26.0+ - visionOS ``` -------------------------------- ### Method: prepare(for:) Source: https://developer.apple.com/documentation/realitykit/postprocesseffect/prepare%28for%3A%29 Documentation for the prepare(for:) instance method used to perform initial setup work on a Metal device. ```APIDOC ## prepare(for:) ### Description A method where you can prepare the metal device with initial setup work. RealityKit calls this method once after setting or updating the customPostProcessing property, before rendering the next frame. ### Method Instance Method ### Parameters #### Parameters - **device** (any MTLDevice) - Required - The Metal device to prepare. ### Declaration ```swift nonisolated mutating func prepare(for device: any MTLDevice) ``` ### Discussion Adding long-running tasks in this method may cause rendering hitches. ``` -------------------------------- ### Get and Set Quaternion fromValue in RealityKit Source: https://developer.apple.com/documentation/realitykit/fromtobyanimation/fromvalue-12wzs Use this property to get or set the starting quaternion value for animations. Available when the animation's value type is `simd_quatf`. ```swift var fromValue: simd_quatf? { get set } ``` -------------------------------- ### Define prepare(for:) method signature Source: https://developer.apple.com/documentation/realitykit/postprocesseffect/prepare%28for%3A%29 Use this method to perform initial setup on the Metal device. Avoid long-running tasks to prevent rendering hitches. ```swift nonisolated mutating func prepare(for device: any MTLDevice) ``` -------------------------------- ### init(from:) Source: https://developer.apple.com/documentation/realitykit/entity/configurationcatalog/init%28from%3A%29 Initializes a configuration catalog from a specified URL pointing to a USD or .reality file. ```APIDOC ## init(from:) ### Description Loads a configuration catalog from a USD or .reality file. This method parses the file to provide a collection of available configurations based on USD variant sets or .reality file configurations without loading large assets like textures or meshes. ### Method Initializer ### Parameters #### Path Parameters - **url** (URL) - Required - A URL of a USD or .reality file. ### Request Example init(from: url) ### Response #### Success Response - **ConfigurationCatalog** (Object) - A collection of available configurations. ``` -------------------------------- ### GET /FromToByAnimation/fromValue Source: https://developer.apple.com/documentation/realitykit/fromtobyanimation/fromvalue-66cs6 Accesses the starting value for a FromToByAnimation instance when the animation type is BlendShapeWeights. ```APIDOC ## Property: fromValue ### Description The starting value for the animation. This property is available when the animation's Value type is BlendShapeWeights. ### Declaration `var fromValue: BlendShapeWeights? { get set }` ### Availability - iOS 18.0+ - iPadOS 18.0+ - Mac Catalyst 18.0+ - macOS 15.0+ - tvOS 26.0+ - visionOS 2.0+ ``` -------------------------------- ### Get PhotogrammetrySession.Pose Rotation Source: https://developer.apple.com/documentation/realitykit/photogrammetrysession/pose/rotation Access the rotation property to get the orientation of the pose relative to the reference coordinate system. Available on iOS, iPadOS, macOS, and Mac Catalyst starting from version 17.0. ```swift let rotation: simd_quatf ``` -------------------------------- ### Initializer: init(background:lighting:reverb:) Source: https://developer.apple.com/documentation/realitykit/arview/environment-swift.struct/init%28background%3Alighting%3Areverb%3A%29 Creates a new environment description with the specified background, lighting, and reverb elements. ```APIDOC ## Initializer: init(background:lighting:reverb:) ### Description Creates a new environment description with the given elements for an ARView. ### Parameters - **background** (ARView.Environment.Background) - Required - The background configuration for the environment. - **lighting** (ARView.Environment.ImageBasedLight) - Required - The image-based lighting configuration. - **reverb** (ARView.Environment.Reverb) - Required - The reverb configuration for the environment. ### Signature ```swift init( background: ARView.Environment.Background, lighting: ARView.Environment.ImageBasedLight, reverb: ARView.Environment.Reverb ) ``` ``` -------------------------------- ### Prepare Metal Device for Post-Processing Source: https://developer.apple.com/documentation/realitykit/postprocesseffect Implement this method to perform initial setup work for the Metal device. A default implementation is provided. ```swift func prepare(for: any MTLDevice) ``` -------------------------------- ### GET AnimationTimingFunction.easeInOut Source: https://developer.apple.com/documentation/realitykit/animationtimingfunction/easeinout Retrieves the easeInOut timing function property which produces a gradual starting and ending transition. ```APIDOC ## static var easeInOut ### Description A timing function that produces a gradual starting and ending transition. ### Availability - iOS 13.0+ - iPadOS 13.0+ - Mac Catalyst 13.0+ - macOS 10.15+ - tvOS 26.0+ - visionOS ### Declaration ```swift static var easeInOut: AnimationTimingFunction { get } ``` ``` -------------------------------- ### Create and play a VideoMaterial Source: https://developer.apple.com/documentation/realitykit/videomaterial Demonstrates initializing a VideoMaterial from a local bundle file, configuring spatial audio, and starting playback. ```swift // Create a URL that points to the movie file. if let url = Bundle.main.url(forResource: "MyMovie", withExtension: "mp4") { // Create an AVPlayer instance to control playback of that movie. let player = AVPlayer(url: url) // Instantiate and configure the video material. let material = VideoMaterial(avPlayer: player) // Configure audio playback mode. material.controller.audioInputMode = .spatial // Create a new model entity using the video material. let modelEntity = ModelEntity(mesh: cube, materials: [material]) // Start playing the video. player.play() } ``` -------------------------------- ### GET ActionEventType.updated Source: https://developer.apple.com/documentation/realitykit/actioneventtype/updated Retrieves the updated event type, which occurs after an action event starts and remains within its time interval. ```APIDOC ## GET ActionEventType.updated ### Description An event that takes place after an action event starts and is within its time interval. ### Method GET ### Endpoint static var updated: ActionEventType ### Response #### Success Response (200) - **updated** (ActionEventType) - The event type representing an update during an action interval. ``` -------------------------------- ### init(source:) Source: https://developer.apple.com/documentation/realitykit/virtualenvironmentprobecomponent/init%28source%3A%29 Initializes a new VirtualEnvironmentProbeComponent with a specified lighting source. ```APIDOC ## init(source:) ### Description Creates a virtual-environment probe component. ### Parameters #### Parameters - **source** (VirtualEnvironmentProbeComponent.Source) - Optional - An enumeration describing the source of environment lighting. Defaults to .none. ### Request Example ```swift let probe = VirtualEnvironmentProbeComponent(source: .none) ``` ``` -------------------------------- ### Set Up AudioLibraryComponent on an Entity Source: https://developer.apple.com/documentation/realitykit/audiolibrarycomponent This example demonstrates how to create an AudioLibraryComponent, load audio resources, add them to the component with custom names, and then attach the component to an entity. It also shows how to play an audio resource using its assigned name. ```swift let humanEntity = Entity() let walkFileResource = try AudioFileResource.load(named: "HumanWalk") let jumpFileResource = try AudioFileResource.load(named: "HumanJump") let groupResource = try AudioFileGroupResource([walkFileResource, jumpFileResource]) var audioLibraryComponent = AudioLibraryComponent() audioLibraryComponent.resources["Walk"] = walkFileResource audioLibraryComponent.resources["Jump"] = jumpFileResource audioLibraryComponent.resources["group"] = groupResource humanEntity.components.set(audioLibraryComponent) humanEntity.playAudio(audioLibraryComponent.resources["Walk"]!) ``` -------------------------------- ### Get and Set JointTransforms fromValue Source: https://developer.apple.com/documentation/realitykit/fromtobyanimation/fromvalue-2h2wq Use this property to get or set the starting value for animations when the value type is JointTransforms. Available on iOS 15.0+, iPadOS 15.0+, Mac Catalyst 15.0+, macOS 12.0+, tvOS 26.0+, and visionOS. ```swift var fromValue: JointTransforms? { get set } ``` -------------------------------- ### init(tracking:sceneUnderstanding:camera:) Source: https://developer.apple.com/documentation/realitykit/spatialtrackingsession/configuration/init%28tracking%3Asceneunderstanding%3Acamera%3A%29 Creates a configuration with anchor capabilities, scene-understanding capabilities, and camera feeds. ```APIDOC ## init(tracking:sceneUnderstanding:camera:) ### Description Creates a configuration with anchor capabilities, scene-understanding capabilities, and camera feeds. ### Parameters #### Parameters - **tracking anchorCapabilities** (Set) - Optional - The set of anchor capabilities to run with a `SpatialTrackingSession`. - **sceneUnderstanding** (Set) - Optional - The set of scene-understanding capabilities to run with a `SpatialTrackingSession`. - **camera** (SpatialTrackingSession.Configuration.Camera) - Optional - The camera feed to run with a `SpatialTrackingSession`. ``` -------------------------------- ### init(resources:) Source: https://developer.apple.com/documentation/realitykit/lowlevelrenderer/init%28resources%3A%29 Creates a renderer using pre-compiled GPU resources. This is a Beta API. ```APIDOC ## init(resources:) ### Description Creates a renderer using pre-compiled GPU resources. ### Method `init(resources: LowLevelRenderer.Resources) throws(LowLevelRendererError)` ### Parameters #### Parameters - **resources** (LowLevelRenderer.Resources) - Required - Pre-compiled GPU resources for this renderer’s configuration. ``` -------------------------------- ### Animating Entity Transform Source: https://developer.apple.com/documentation/realitykit/fromtobyaction Example of creating and playing an animation to move an entity using FromToByAction with specified start and end transforms. ```APIDOC ### Create a from, to, by action to animate an entity’s transform property The example below creates an animation which gradually animates the bound entities transform property for five seconds with a linear transition. ```swift // Create a transform to start animating from. let startTransform = Transform(translation: [0.0, 2.0, 0.0]) // Create a transform to animate towards. let endTransform = Transform(translation: [0.0, -2.0, 0.0]) // Create an action that gradually animates a transform value. // // This starts `from` a specified value, and animates towards // a specified `to` value. // // The bound entity will move in the space relative to its parent. let transformAction = FromToByAction(from: startTransform, to: endTransform, mode: .parent, timing: .linear, isAdditive: false) // A five second animation that plays an animation causing // the entity to gradually move from a specific start, and end transform let transformAnimation = try AnimationResource .makeActionAnimation(for: transformAction, duration: 5.0, bindTarget: .transform) // Play the five second animation on the entity that will cause it to move. entity.playAnimation(transformAnimation) ``` **Important**: This action animates various bound properties, for example `BindTarget.transform` on the bound entity. Ensure a correct bind target is supplied when creating the animation. **Note**: For more information on the combination of inputs this action supports see `FromToByAnimation`. **Important**: If you do not provide values for any of the `from`, `to`, and `by` parameters, the animation stays at the default source value. ``` -------------------------------- ### Get Start Index of Animation Collection Source: https://developer.apple.com/documentation/realitykit/animationlibrarycomponent/animationcollection/index Retrieves the index of the first animation in the collection. This is useful for iterating from the beginning of an animation sequence. ```swift var startIndex: AnimationLibraryComponent.AnimationCollection.Index ``` -------------------------------- ### start(imagesDirectory:configuration:) Source: https://developer.apple.com/documentation/realitykit/objectcapturesession/start%28imagesdirectory%3Aconfiguration%3A%29 Initiates the ObjectCaptureSession, defining the directory for saving captured images and allowing for optional configuration of session parameters. The provided `imagesDirectory` must be empty and writable, or it will be created. If a `checkpointDirectory` is also provided, it must be empty if it exists. This method can only be called once on a new session. ```APIDOC ## start(imagesDirectory:configuration:) ### Description Starts the session with the provided output image directory and optional checkpoint directory. ### Method func ### Endpoint ObjectCaptureSession.start ### Parameters #### Path Parameters - **imagesDirectory** (URL) - Required - A directory to save the images. - **configuration** (ObjectCaptureSession.Configuration) - Optional - A configuration specifying session options. ### Discussion The directory that `imagesDirectory` points to needs to be an empty and writable directory or it is an error. Likewise, if `checkpointDirectory` is provided, it needs to be empty if it already exists. If the directory does not exist, it is created for you. If it cannot be, the session moves to `.failed` state. This call is only valid once on a newly created session. ``` -------------------------------- ### Accessing the LightmapResource Source: https://developer.apple.com/documentation/realitykit/lightmapcomponent/lightmap Use this property to get or set the LightmapResource associated with the component. Available on multiple Apple platforms starting from iOS 27.0 Beta. ```swift var lightmap: LightmapResource { get set } ``` -------------------------------- ### init(scene:) Source: https://developer.apple.com/documentation/realitykit/system/init%28scene%3A%29 Initializes a new system for a specific RealityKit scene. ```APIDOC ## init(scene:) ### Description Creates a new system instance for a given scene. Note that developers should not call this method directly; instead, register systems using registerSystem(). ### Parameters #### Parameters - **scene** (Scene) - Required - The scene this system affects. ### Discussion There is no need to instantiate your own systems. RealityKit automatically creates an instance of every registered system for every scene. ``` -------------------------------- ### Get billboardBlendFactor Property Source: https://developer.apple.com/documentation/realitykit/bindtarget/entitypath/billboardblendfactor Accesses the billboardBlendFactor property, which returns a BindTarget. This property is available on multiple Apple platforms starting from specific OS versions. ```swift var billboardBlendFactor: BindTarget { get } ``` -------------------------------- ### Property: prepareWithDevice Source: https://developer.apple.com/documentation/realitykit/arview/rendercallbacks-swift.struct/preparewithdevice A callback function for performing initial setup work, specifically for Metal device initialization. ```APIDOC ## Property: prepareWithDevice ### Description A callback function for doing initial setup work. RealityKit calls this function once after its own setup work is complete, but before rendering the next frame. ### Signature `var prepareWithDevice: ((any MTLDevice) -> Void)?` ### Usage To register the function, assign it to the `prepareWithDevice` property of the view’s `renderCallbacks` property: ```swift arView.renderCallbacks.prepareWithDevice = myPostProcessSetupCallback ``` To remove the callback, assign `nil`: ```swift arView.renderCallbacks.prepareWithDevice = nil ``` ### Availability - iOS 15.0+ - iPadOS 15.0+ - Mac Catalyst 15.0+ - macOS 12.0+ - tvOS 26.0+ ``` -------------------------------- ### prepareAudio(configuration:_:) Method Source: https://developer.apple.com/documentation/realitykit/entity/prepareaudio%28configuration%3A_%3A%29 Prepares a real-time audio playback instance. This method is suitable for generating audio on the fly and provides an AudioGeneratorController for managing playback. ```APIDOC ## POST /websites/developer_apple_realitykit/prepareAudio ### Description Prepares a real-time audio playback instance. The system runs the provided handler to generate real-time audio. Use the returned controller to manage playback. ### Method POST ### Endpoint /websites/developer_apple_realitykit/prepareAudio ### Parameters #### Request Body - **configuration** (AudioGeneratorConfiguration) - Optional - A set of configuration parameters necessary for initializing and rendering the `generatorRenderHandler`. - **generatorRenderHandler** (Audio.GeneratorRenderHandler) - Required - The audio render handler to prepare. The system runs this handler to generate real-time audio. ### Request Example ```json { "configuration": {}, "generatorRenderHandler": "// Swift code for audio generation handler" } ``` ### Response #### Success Response (200) - **AudioGeneratorController** (object) - An instance that you use to manage audio playback. Use the controller to set the volume and start or stop playback. #### Response Example ```json { "audioGeneratorController": { "volume": 1.0, "isPlaying": false } } ``` ### See Also - `playAudio(configuration: AudioGeneratorConfiguration, Audio.GeneratorRenderHandler) throws -> AudioGeneratorController` - `playAudio(AudioResource) -> AudioPlaybackController` - `prepareAudio(AudioResource) -> AudioPlaybackController` - `stopAllAudio()` - `spatialAudio` (SpatialAudioComponent?) - `ambientAudio` (AmbientAudioComponent?) - `channelAudio` (ChannelAudioComponent?) ``` -------------------------------- ### Get Default SpatialTrackingSession Configuration Source: https://developer.apple.com/documentation/realitykit/spatialtrackingsession/configuration/supportedconfiguration%28%29 Use this method to retrieve the default configuration for a spatial tracking session. This is the recommended starting point for configuring a new session. ```swift func supportedConfiguration() -> SpatialTrackingSession.Configuration ``` -------------------------------- ### position Source: https://developer.apple.com/documentation/realitykit/lowlevelrenderer/camera/position Gets or sets the position of the camera in world space. This property is available for iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 and is in Beta. ```APIDOC ## position ### Description The position of the camera in world space. ### Property - **position** (SIMD3) - Gets or sets the camera's position. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ### Example ```swift var position: SIMD3 { get set } ``` ``` -------------------------------- ### init(contentsOf:withName:configuration:) Source: https://developer.apple.com/documentation/realitykit/audiofileresource/init%28contentsof%3Awithname%3Aconfiguration%3A%29 Initializes an AudioFileResource asynchronously from a specified URL. ```APIDOC ## init(contentsOf:withName:configuration:) ### Description Initializes an AudioFileResource asynchronously. ### Method Initializer ### Parameters #### Parameters - **contentsOf** (URL) - Required - The URL of the audio file. - **withName** (String?) - Optional - The name of the resource. - **configuration** (AudioFileResource.Configuration) - Optional - The configuration settings for the audio resource. ### Request Example ```swift let resource = try await AudioFileResource(contentsOf: url, withName: "myAudio", configuration: .init()) ``` ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/realitykit/manipulationcomponent/inputdevice/kind-swift.enum/set/init%28_%3A%29 Initializes a set of input device kinds with a single specified kind. ```APIDOC ## init(_:) ### Description Creates a set of input device kinds containing only the specified input device kind. ### Parameters #### Parameters - **kind** (ManipulationComponent.InputDevice.Kind) - Required - The input device kind to include in the set. ### Request Example init(ManipulationComponent.InputDevice.Kind.hand) ``` -------------------------------- ### Instance Subscript for Entity.ComponentSet Source: https://developer.apple.com/documentation/realitykit/entity/componentset/subscript%28_%3A%29-5wdsf Gets or sets the component of the specified type. Available on iOS, iPadOS, Mac Catalyst, macOS, tvOS, and visionOS starting from version 27.0. ```swift @abi(@MainActor @preconcurrency subscript(optimized componentType: T.Type) -> T? where T : Component { get set }) @MainActor @preconcurrency subscript(componentType: T.Type) -> T? where T : Component { get set } ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/realitykit/pointlightcomponent/surroundingslight/init%28%29 Creates a new surroundings light object. ```APIDOC ## init() ### Description Creates a new surroundings light object. ### Method initializer ### Endpoint N/A (SDK method) ### Parameters None ### Request Example ```swift let surroundingsLight = PointLightComponent.SurroundingsLight() ``` ### Response #### Success Response - **PointLightComponent.SurroundingsLight**: A new surroundings light object. ``` -------------------------------- ### ClothCoordinateSpace.local Source: https://developer.apple.com/documentation/realitykit/clothcoordinatespace/local Gets a cloth coordinate space reference frame that is local to the entity. Available on iOS, iPadOS, Mac Catalyst, and visionOS starting from version 27.0 (Beta). ```APIDOC ## local ### Description Gets a cloth coordinate space reference frame that is local to the entity. ### Property `static var local: ClothCoordinateSpace { get }` ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### Get Default Dynamic Range in RealityKit Source: https://developer.apple.com/documentation/realitykit/realityviewdynamicrange/default Access the default dynamic range setting for RealityKit content. This property is available on multiple Apple platforms starting from iOS 18.0. ```swift static var `default`: RealityViewDynamicRange { get } ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/realitykit/spotlightcomponent/shadow/init%28%29 Creates a new spot light shadow object. This initializer does not take any arguments. ```APIDOC ## init() ### Description Creates a new spot light shadow object. ### Method initializer ### Parameters This initializer does not take any parameters. ### Request Example ```swift init() ``` ### Response This initializer does not return a value directly, but creates an instance of SpotLightComponent.Shadow. ``` -------------------------------- ### Get Target Count Source: https://developer.apple.com/documentation/realitykit/lowleveldeformation/descriptor-swift.struct/blending-swift.struct/targetcount Retrieves the number of blend-shape targets associated with a descriptor. This property is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0. ```swift var targetCount: Int ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/realitykit/physicallybasedmaterial/clearcoat-swift.struct/init%28_%3A%29 Initializes a clearcoat object using a CustomMaterial.Clearcoat property. ```APIDOC ## init(_:) ### Description Creates a clearcoat object from a custom material’s clearcoat property. ### Parameters #### Path Parameters - **value** (CustomMaterial.Clearcoat) - Required - The custom material’s clearcoat property. ### Request Example init(value: customMaterialClearcoatInstance) ``` -------------------------------- ### init(named:from:in:) Source: https://developer.apple.com/documentation/realitykit/audiofileresource/init%28named%3Afrom%3Ain%3A%29 Initializes a preconfigured AudioFileResource asynchronously from a Reality Composer Pro project. ```APIDOC ## init(named:from:in:) ### Description Initializes a preconfigured AudioFileResource asynchronously from a Reality Composer Pro project with the given name as the prim-path of the AudioFile, and the scene as the name of the USD file name. ### Parameters #### Path Parameters - **name** (String) - Required - The prim-path of the AudioFile. - **scene** (String) - Required - The name of the USD file. - **bundle** (Bundle?) - Optional - The bundle containing the resource. ### Request Example ```swift let audioResource = try await AudioFileResource(named: "myAudio", from: "myScene.usda", in: Bundle.main) ``` ``` -------------------------------- ### Accessing the size of a LowLevelBufferSlice Source: https://developer.apple.com/documentation/realitykit/lowlevelbufferslice/size Use this property to get the size of the buffer slice in bytes. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0. ```swift var size: Int { get } ``` -------------------------------- ### init(named:from:in:) Source: https://developer.apple.com/documentation/realitykit/audiofileresource/init%28named%3Ain%3Aconfiguration%3A%29 Initializes a preconfigured AudioFileResource asynchronously from a Reality Composer Pro project. ```APIDOC ## init(named:from:in:) ### Description Initializes a preconfigured AudioFileResource asynchronously from a Reality Composer Pro project with the given name as the prim-path of the AudioFile, and the scene as the name of the USD file name. ### Method Initializer ### Parameters #### Parameters - **named** (String) - Required - The prim-path of the AudioFile. - **from** (String) - Required - The name of the USD file (scene). - **in** (Bundle?) - Optional - The bundle containing the resource. ``` -------------------------------- ### atlasTextureSlice Source: https://developer.apple.com/documentation/realitykit/lightmapresource/atlasreference/atlastextureslice Gets the index of the texture slice within the atlas. This is a beta property available on iOS, iPadOS, Mac Catalyst, macOS, tvOS, and visionOS starting from version 27.0. ```APIDOC ## atlasTextureSlice ### Description Index of the slice within the atlas. ### Property `var atlasTextureSlice: Int` ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### Get Default Reverb Preset Source: https://developer.apple.com/documentation/realitykit/arview/environment-swift.struct/reverb-swift.enum/automatic Use this static property to access the default reverb preset for ARView environments. No specific setup is required beyond standard ARView initialization. ```swift static var automatic: ARView.Environment.Reverb { get } ``` -------------------------------- ### Create optimized environment resource with compression Source: https://developer.apple.com/documentation/realitykit/environmentresource/init%28cube%3Aoptions%3A%29-9j9rn Example demonstrating how to configure high-quality sampling and ASTC compression for optimized environment resources. ```swift // Use compression and high quality options to export optimized resources. let cube = try TextureResource( cubeFromEquirectangular: image, quality: .high, options: TextureResource.CreateOptions(semantic: .color) ) let options = EnvironmentResource.CreateOptions( samplingQuality: .high, specularCubeDimension: cube.width/2, compression: .astc(blockSize: .block4x4, quality: .high) ) let environment = try EnvironmentResource( cube: cube, options: EnvironmentResource.CreateOptions( samplingQuality: .high, specularCubeDimension: cube.width/2, compression: .astc(blockSize: .block4x4, quality: .high) ) ) let lightEntity = Entity() lightEntity.components.set(ImageBasedLightComponent( source: .single(environment) )) ... ``` -------------------------------- ### init(resource:) Source: https://developer.apple.com/documentation/realitykit/ikcomponent/init%28resource%3A%29 Initializes a new IKComponent with a specified IK resource. ```APIDOC ## init(resource:) ### Description Creates a new component value referencing the specified resource. ### Parameters #### Parameters - **resource** (IKResource?) - Optional - The resource with the desired IK rig for the new solver. ### Request Example init(resource: myIKResource) ``` -------------------------------- ### Accessing the materialIndex property Source: https://developer.apple.com/documentation/realitykit/meshresource/part/materialindex Use this property to get or set the material index for a mesh part. It is available across multiple Apple platforms starting from iOS 15.0 and macOS 12.0. ```swift var materialIndex: Int { get set } ``` -------------------------------- ### init(device: any MTLDevice) Source: https://developer.apple.com/documentation/realitykit/lowlevelrendercontextstandalone/configuration Creates a configuration using the given Metal device. ```APIDOC ## init(device: any MTLDevice) ### Description Creates a configuration using the given device. ### Parameters #### Path Parameters - **device** (any MTLDevice) - Required - The Metal device to use for all rendering operations. ``` -------------------------------- ### Get renderTargetArrayIndex Source: https://developer.apple.com/documentation/realitykit/lowlevelrenderer/camera/rendertargetarrayindex Retrieves the index into the render target texture array slice for the camera. This property is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0. ```swift var renderTargetArrayIndex: Int { get set } ``` -------------------------------- ### Get and Set bufferIndex Source: https://developer.apple.com/documentation/realitykit/lowlevelmaterialparametermapping/constantlocation/bufferindex Access the buffer slot index within the argument table. This property is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0. ```swift var bufferIndex: Int { get set } ``` -------------------------------- ### Initializer: init(resources:) Source: https://developer.apple.com/documentation/realitykit/audiolibrarycomponent/init%28resources%3A%29 Creates a new audio library from a dictionary of audio resources. ```APIDOC ## Initializer: init(resources:) ### Description Creates a new audio library from a dictionary. ### Method Initializer ### Endpoint N/A (Initializer) ### Parameters #### Request Body - **resources** (Dictionary) - Optional - A dictionary of audio resources that you key by name. ### Request Example ```swift init(resources: [String : AudioResource] = [:]) ``` ### Response #### Success Response (200) N/A (Initializer) #### Response Example N/A (Initializer) ``` -------------------------------- ### init(named:in:configuration:) Source: https://developer.apple.com/documentation/realitykit/audiofileresource/init%28named%3Afrom%3Ain%3A%29 Initializes an AudioFileResource asynchronously from a bundle. ```APIDOC ## init(named:in:configuration:) ### Description Initializes an AudioFileResource asynchronously. ### Parameters #### Path Parameters - **named** (String) - Required - The name of the audio resource. - **in** (Bundle?) - Optional - The bundle containing the resource. - **configuration** (AudioFileResource.Configuration) - Required - The configuration settings for the audio file. ``` -------------------------------- ### Get and Set contentScaleFactor in RealityKit Source: https://developer.apple.com/documentation/realitykit/arview/contentscalefactor This property indicates the scale factor of the content within the ARView. It is available on iOS, iPadOS, and Mac Catalyst starting from version 13.0, and tvOS from version 26.0. ```swift @MainActor @preconcurrency override dynamic var contentScaleFactor: CGFloat { get set } ``` -------------------------------- ### init(configurationSets:combinations:) Source: https://developer.apple.com/documentation/realitykit/entity/configurationcatalog/init%28configurationsets%3Acombinations%3A%29 Initializes a new configuration catalog using provided configuration sets and combinations of entities. ```APIDOC ## init(configurationSets:combinations:) ### Description Creates a configuration catalog from in-memory entities and an array of configuration sets. ### Parameters - **configurationSets** ([Entity.ConfigurationCatalog.ConfigurationSet]) - Required - The configuration choices that the configuration catalog presents. Each set must have a unique ID. - **combinations** ([Entity.ConfigurationCatalog.ConfigurationCombination]) - Required - The combinations of in-memory entities and the configurations that can address them. ### Return Value A configuration catalog that maintains the provided entities in memory. ### Declaration ```swift init( configurationSets: [Entity.ConfigurationCatalog.ConfigurationSet], combinations: [Entity.ConfigurationCatalog.ConfigurationCombination] ) throws ``` ``` -------------------------------- ### tint Source: https://developer.apple.com/documentation/realitykit/physicallybasedmaterial/basecolor-swift.struct/tint-2znu0 Gets or sets the UIColor tint applied to the base color of the material. This property is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from their respective version 15.0 (or 26.0 for tvOS). ```APIDOC ## tint ### Description Gets or sets the `UIColor` tint applied to the base color of the material. This property is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from their respective version 15.0 (or 26.0 for tvOS). ### Method `var tint: UIColor { get set }` ### Parameters None ### Response #### Success Response - **tint** (`UIColor`) - The current color tint applied to the base color. ``` -------------------------------- ### cameraPosition Instance Property Source: https://developer.apple.com/documentation/realitykit/lowlevelrenderer/sortconfiguration/cameraposition Gets or sets the camera position used for per-instance sorting of transparent draw calls. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0. ```swift var cameraPosition: SIMD3 { get set } ``` -------------------------------- ### init(configuration:content:) Source: https://developer.apple.com/documentation/realitykit/presentationcomponent/init%28configuration%3Acontent%3A%29 Initializes a PresentationComponent to display SwiftUI content with specific configuration settings. ```APIDOC ## init(configuration:content:) ### Description Present content using modality and options specified by configuration. A component created using this method will have its isPresented property default to true, which means it will present as soon as an entity with the component is added to the hierarchy. ### Parameters - **configuration** (PresentationComponent.Configuration) - Required - A configuration that specifies the modality, appearance, and behavior of the presentation. - **content** (Content) - Required - The SwiftUI view hierarchy that you want to present with the component. ### Request Example ```swift init( configuration: PresentationComponent.Configuration, content: Content ) where Content : View ``` ``` -------------------------------- ### init(from:configurations:) Source: https://developer.apple.com/documentation/realitykit/entity/init%28from%3Aconfigurations%3A%29 Initializes and loads an entity from a configuration catalog using specified configuration choices. ```APIDOC ## init(from:configurations:) ### Description Loads an entity from a configuration catalog and a dictionary of configuration choices. ### Method Initializer ### Parameters #### Path Parameters - **catalog** (Entity.ConfigurationCatalog) - Required - A collection of alternative representations for an entity. - **configurations** ([String : String]?) - Optional - A dictionary of configuration choices the initializer applies as it loads the entity, mapping the ID of a configuration set to the ID of a configuration within that set. ### Request Example @MainActor @preconcurrency convenience init( from catalog: Entity.ConfigurationCatalog, configurations: [String : String]? = nil ) async throws ``` -------------------------------- ### RealityView with Frame Updates Source: https://developer.apple.com/documentation/RealityKit/RealityView This example shows how to use the `update` closure of RealityView to perform per-frame updates, such as animating an entity's position. It subscribes to `SceneEvents.Update` to get the delta time for smooth animations. ```APIDOC ## RealityView with Frame Updates ### Description If you want to run code every frame (to do animations or simulations), you can use a `System` or directly subscribe to the engine’s `SceneEvents.Update`. ### Example ```swift RealityView { content in let entity = ModelEntity(mesh: .generateSphere(radius: 0.1)) content.add(entity) _ = content.subscribe(to: SceneEvents.Update.self) { event in entity.position.y -= Float(event.deltaTime) } } ``` ``` -------------------------------- ### Access Material by Name Source: https://developer.apple.com/documentation/realitykit/clothsimulationcomponent/materialcollection/subscript%28_%3A%29 Use this subscript to get a material from the collection by its name. It returns nil if no material with the specified name exists. Available on iOS, iPadOS, Mac Catalyst, and visionOS starting from version 27.0. ```swift subscript(name: String) -> ClothSimulationComponent.Material? { get set } ``` -------------------------------- ### init(named:in:configuration:) Source: https://developer.apple.com/documentation/realitykit/audiofileresource/init%28named%3Ain%3Aconfiguration%3A%29 Initializes an AudioFileResource asynchronously using a name, bundle, and configuration. ```APIDOC ## init(named:in:configuration:) ### Description Initializes an AudioFileResource asynchronously. ### Method Initializer ### Parameters #### Parameters - **named** (String) - Required - The name of the audio file resource. - **in** (Bundle?) - Optional - The bundle containing the resource, defaults to nil. - **configuration** (AudioFileResource.Configuration) - Optional - The configuration for the resource, defaults to .init(). ### Response - **Returns** (AudioFileResource) - An asynchronously initialized AudioFileResource instance. ``` -------------------------------- ### Subscribe to VideoPlayer Events Source: https://developer.apple.com/documentation/realitykit/videoplayercomponent This example demonstrates how to subscribe to various events emitted by the VideoPlayerComponent, such as video size changes, viewing mode changes, and content type changes. Ensure the AVPlayer is configured and playback is started before subscribing. ```swift RealityView { content in let entity = Entity() let player = AVPlayer(url: "PLACEMENT_URL") let videoPlayerComponent = VideoPlayerComponent(avPlayer: player) player.play() entity.components.set(videoPlayerComponent) var subscription: EventSubscription? subscription = content.subscribe(to: VideoPlayerEvents.VideoSizeDidChange.self) { event in print("video size did change: \(event.videoDimension)") } subscription = content.subscribe(to: VideoPlayerEvents.ViewingModeDidChange.self) { event in print("viewing mode did change: \(event.currentViewingMode)") } subscription = content.subscribe(to: VideoPlayerEvents.ContentTypeDidChange.self) { event in print("content type did change: \(event.contentType.rawValue)") } content.add(entity) } ``` -------------------------------- ### Retrieve PortalMaterial Parameter by Name Source: https://developer.apple.com/documentation/realitykit/portalmaterial/getparameter%28name%3A%29 Use this method to get the current value of a shader parameter by its name. Returns nil if the parameter is not set. Available on iOS, iPadOS, macOS, tvOS, and visionOS starting from version 27.0. ```swift func getParameter(name: String) -> MaterialParameters.Value? ``` -------------------------------- ### VideoMaterial Initialization and Usage Source: https://developer.apple.com/documentation/realitykit/videomaterial Documentation for creating and configuring a VideoMaterial instance. ```APIDOC ## init(avPlayer: AVPlayer) ### Description Creates a new video material using an AVPlayer instance to control movie playback. ### Parameters #### Request Body - **avPlayer** (AVPlayer) - Required - The player instance used to control the movie playback. ### Request Example let player = AVPlayer(url: url) let material = VideoMaterial(avPlayer: player) ``` -------------------------------- ### textureIndex Source: https://developer.apple.com/documentation/realitykit/lowlevelmaterialparametermapping/textureparameter/textureindex Gets or sets the slot index within the argument table's texture array for a texture parameter. This property is available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## textureIndex ### Description Gets or sets the slot index within the argument table's texture array. ### Property `var textureIndex: Int { get set }` ### Availability iOS 27.0+ (Beta) iPadOS 27.0+ (Beta) Mac Catalyst 27.0+ (Beta) tvOS 27.0+ (Beta) visionOS 27.0+ (Beta) ``` -------------------------------- ### Register a prepareWithDevice Callback Source: https://developer.apple.com/documentation/realitykit/arview/rendercallbacks-swift.struct/preparewithdevice Assign your setup function to the prepareWithDevice property of the ARView's renderCallbacks to register it. ```swift arView.renderCallbacks.prepareWithDevice = myPostProcessSetupCallback ``` -------------------------------- ### Set up a video player component Source: https://developer.apple.com/documentation/realitykit/videoplayercomponent/init%28avplayer%3A%29 Demonstrates creating an AVPlayer, initializing a VideoPlayerComponent, and attaching it to an entity. Note that an AVPlayer object cannot be shared across multiple VideoPlayerComponent instances. ```swift // Create an entity for display. let videoEntity = Entity() // Create an AV player with a URL. let player = AVPlayer(url: "PLACEMENT_URL") // Create a video player component with the AV player. let videoPlayerComponent = VideoPlayerComponent(avPlayer: player) // Attach the video player component to the entity. videoEntity.components.set(videoPlayerComponent) ``` -------------------------------- ### Accessing the Local Cloth Coordinate Space Source: https://developer.apple.com/documentation/realitykit/clothcoordinatespace/local Use this static property to get the `ClothCoordinateSpace` that represents the local entity's reference frame. Available on iOS, iPadOS, Mac Catalyst, and visionOS starting from version 27.0 (Beta). ```swift static var local: ClothCoordinateSpace { get } ``` -------------------------------- ### Create an environment resource from a cube texture Source: https://developer.apple.com/documentation/realitykit/textureresource/init%28cubefromimage%3Anamed%3Aoptions%3A%29 Example showing how to load an image, create a cube texture, and use it to configure an ImageBasedLightComponent. ```swift if let source = CGImageSourceCreateWithURL(url as CFURL, nil), let image = CGImageSourceCreateImageAtIndex(source, 0, nil) { // Create a cube texture from the image. let cube = try await TextureResource( cubeFromImage: image, options: TextureResource.CreateOptions(semantic: .hdrColor)) // Create an environment resource from the cube texture. let environment = try await EnvironmentResource( cube: cube, options: EnvironmentResource.CreateOptions()) await MainActor.run { // Assign the environment to an image-based light component. let lightEntity = Entity() lightEntity.components.set( ImageBasedLightComponent(source: .single(environment))) ... } } ``` -------------------------------- ### Setup AVAssetReader for Side-by-Side Video Source: https://developer.apple.com/documentation/realitykit/rendering-stereoscopic-video-with-realitykit Configures an AVAssetReader to read video frames from the loaded track. It specifies IOSurface properties for pixel buffer allocation and creates a track output provider. The reader is then started to begin frame extraction. ```swift // Setup the asset reader. let readerSettings: [String: Any] = [ kCVPixelBufferIOSurfacePropertiesKey as String: [String: String]() ] let videoTrackOutput = AVAssetReaderTrackOutput(track: videoTrack, outputSettings: readerSettings) let assetReader = try AVAssetReader(asset: asset) let videoTrackOutputProvider = assetReader.outputProvider(for: videoTrackOutput) try assetReader.start() ``` -------------------------------- ### Create and Configure VideoMaterial Source: https://developer.apple.com/documentation/realitykit/videomaterial/init%28avplayer%3A%29 Demonstrates creating an AVPlayer from a local resource and applying it to a ModelEntity. ```swift // Create a URL that points to the movie file. if let url = Bundle.main.url(forResource: "MyMovie", withExtension: "mp4") { // Create an AVPlayer instance to control playback of that movie. let player = AVPlayer(url: url) // Instantiate and configure the video material. let material = VideoMaterial(avPlayer: player) // Configure audio playback mode. This is optional for movie // files that contain sound. material.controller.audioInputMode = .spatial // Create a new model entity using the video material. let modelEntity = ModelEntity(mesh: cube, materials: [material]) // Start playing the video. player.play() } ``` -------------------------------- ### Get and Set linearDamping Property Source: https://developer.apple.com/documentation/realitykit/physicsbodycomponent/lineardamping Use this property to control how quickly a dynamic rigid body's translation motion slows down to rest. Available on iOS, iPadOS, Mac Catalyst, macOS, tvOS, and visionOS starting from their respective versions. ```swift var linearDamping: Float { get set } ``` -------------------------------- ### Accessing a Mesh Instance by Index Source: https://developer.apple.com/documentation/realitykit/lowlevelmeshinstancearray/subscript%28_%3A%29 Use this subscript to get a mesh instance at a specific position in the array. Returns nil if the index is out of bounds or the slot is unoccupied. Available on iOS, iPadOS, macOS, tvOS, and visionOS starting from version 27.0. ```swift final subscript(position: Int) -> LowLevelMeshInstance? { get } ``` -------------------------------- ### init(configuration:) Source: https://developer.apple.com/documentation/realitykit/lowlevelrendercontextstandalone/init%28configuration%3A%29 Creates a standalone render context, asynchronously compiling all required shader and pipeline resources. Prefer this overload when creating a single render context. If you need to share compiled resources across multiple contexts, create a `LowLevelRenderContextStandalone.Resources` value first and use `init(configuration:resources:)` instead. ```APIDOC ## init(configuration:) ### Description Creates a standalone render context, asynchronously compiling all required shader and pipeline resources. ### Method `init(configuration: LowLevelRenderContextStandalone.Configuration) async throws` ### Parameters #### Path Parameters - `configuration` (LowLevelRenderContextStandalone.Configuration) - Required - The Metal device and optional memory owner for the new context. ### Discussion Prefer this overload when creating a single render context. If you need to share compiled resources across multiple contexts, create a `LowLevelRenderContextStandalone.Resources` value first and use `init(configuration:resources:)` instead. ``` -------------------------------- ### maxCameraCount Instance Property Source: https://developer.apple.com/documentation/realitykit/lowlevelrenderer/configuration/maxcameracount Use this property to get or set the maximum number of simultaneous cameras supported. The value must be less than or equal to CameraArray.maxCount. Available on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS starting from version 27.0 (Beta). ```swift var maxCameraCount: Int { get set } ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/realitykit/physicsjoints/init%28_%3A%29 Initializes a new instance with a sequence of physics joints. ```APIDOC ## init(_:) ### Description Initializes a new instance using a sequence of physics joints. ### Parameters #### Request Body - **sequence** (any Sequence) - Required - A sequence of physics joints to initialize with. ### Availability - iOS 18.0+ - iPadOS 18.0+ - Mac Catalyst 18.0+ - macOS 15.0+ - tvOS 26.0+ - visionOS 2.0+ ``` -------------------------------- ### init(inputAttributes:outputAttributes:blending:skinning:renormalizing:) Source: https://developer.apple.com/documentation/realitykit/lowleveldeformation/pipeline/descriptor/init%28inputattributes%3Aoutputattributes%3Ablending%3Askinning%3Arenormalizing%3A%29 Creates a pipeline descriptor with configurable input and output attributes, blending, skinning, and renormalizing options. ```APIDOC ## init(inputAttributes:outputAttributes:blending:skinning:renormalizing:) ### Description Creates a pipeline descriptor. ### Parameters #### Initializer Parameters - **inputAttributes** ([LowLevelDeformation.VertexAttribute]?) - Optional array of vertex attributes for the input. - **outputAttributes** ([LowLevelDeformation.VertexAttribute]?) - Optional array of vertex attributes for the output. - **blending** (LowLevelDeformation.Pipeline.Descriptor.Blending?) - Optional blending configuration. - **skinning** (LowLevelDeformation.Pipeline.Descriptor.Skinning?) - Optional skinning configuration. - **renormalizing** (LowLevelDeformation.Pipeline.Descriptor.Renormalizing?) - Optional renormalizing configuration. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta tvOS 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### ObjectCaptureSession.Configuration Source: https://developer.apple.com/documentation/realitykit/objectcapturesession/configuration-swift.property The read-only `Configuration` used to start the capture session. The configuration can be set by passing it to the `start()` call and it remains immutable after the session is started successfully. ```APIDOC ## Instance Property ### configuration The read-only `Configuration` used to start the capture session. The configuration can be set by passing it to the `start()` call and it remains immutable after the session is started successfully. **RealityKit** **SwiftUI** **iOS 17.0+** **iPadOS 17.0+** **Mac Catalyst 17.0+** ```swift @MainActor var configuration: ObjectCaptureSession.Configuration { get } ``` ``` -------------------------------- ### init(buffer:configuration:) Source: https://developer.apple.com/documentation/realitykit/audiobufferresource/init%28buffer%3Aconfiguration%3A%29 Initializes an AudioBufferResource with a provided AVAudioBuffer and configuration. ```APIDOC ## init(buffer:configuration:) ### Description Creates an AudioBufferResource with the given AVAudioBuffer and configuration. ### Parameters - **buffer** (AVAudioBuffer) - Required - The audio buffer to be used for the resource. - **configuration** (AudioBufferResource.Configuration) - Optional - The configuration settings for the resource, defaults to .init(). ### Errors - Throws an error if the given buffer is not or cannot be converted to a non-interleaved PCM buffer. ``` -------------------------------- ### Request Pathfinding from Start to End Source: https://developer.apple.com/documentation/realitykit/navigationcontroller Starts an asynchronous pathfinding operation between a specified start and end point. Use `stopPathfind()` to cancel an ongoing operation. ```swift func requestPath(from: SIMD3, to: SIMD3) ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/realitykit/ikrig/constraint/ikorientationdemand/init%28%29 Initializes a new instance of IKRig.Constraint.IKOrientationDemand with default settings. ```APIDOC ## init() ### Description Creates an orientational demand with default settings. ### Availability - iOS 18.0+ - iPadOS 18.0+ - Mac Catalyst 18.0+ - macOS 15.0+ - tvOS 26.0+ - visionOS 2.0+ ### Syntax ```swift init() ``` ``` -------------------------------- ### Randomize Start Time Source: https://developer.apple.com/documentation/realitykit/audiofileresource/configuration-swift.struct Controls whether playback begins from the start of the file or a random position. Set to true to introduce variation in playback start. ```swift var shouldRandomizeStartTime: Bool ```