Generated from iOS SDK 27.1. Availability is shown on each declaration; permissions and entitlements still apply.
Functions and constants
init · iOS 13.0+init
TypeScriptstatic initRaycastResult(raycastResult: _ARKit_ARRaycastResult): Promise<_RealityFoundation_AnchorEntity>
Swift declaration@MainActor @preconcurrency convenience init(raycastResult: ARRaycastResult)
Creates an anchor entity using the information about a real-world
surface discovered using a ray-cast query.
- Parameters:
- raycastResult: The ray-cast result.
init · iOS 13.0+init
TypeScriptstatic initAnchor(anchor: _ARKit_ARAnchor): Promise<_RealityFoundation_AnchorEntity>
Swift declaration@MainActor @preconcurrency convenience init(anchor: ARAnchor)
Creates an anchor entity that uses an existing AR anchor.
- Parameters:
- anchor: An existing
<doc://com.apple.documentation/documentation/arkit/aranchor> instance.
static · iOS 18.0+generateStaticMesh
TypeScriptstatic generateStaticMesh(meshAnchor: _ARKit_ARMeshAnchor): Promise<_RealityFoundation_ShapeResource>
Swift declarationnonisolated static func generateStaticMesh(from meshAnchor: ARMeshAnchor) async throws -> ShapeResource
Creates a mesh-based collision shape derived from an ARKit Scene Understanding mesh anchor.
The returned `ShapeResource` can only be used under the following circumstances:
- This shape can only be used with `PhysicsBodyMode.static` (not `.dynamic` or `.kinematic`)
- This shape cannot be used with `CollisionComponent.Mode.trigger`
In other words, the returned shape can only be used for static world geometry.
- Note: Generating a shape resource from the AR mesh takes time, because the input mesh needs to be preprocessed
("cooked") by the physics engine before it can be used. This function is marked `async` because ideally
this precomputation should occur in the background. For example, when calling from non-`async` code,
you can use Swift's `Task` API to assign a priority (see the example below).
Below is example usage of this function, assumed to be called from a non-async block:
```swift
let myAnchor: ARMeshAnchor = ...
// It is recommended to use a low-priority task, since generating the collision mesh can take a while.
let myShapeTask = Task(priority: .low) {
let shape = await ShapeResource.generateStaticMesh(from: myAnchor)
// Now we can do something with `shape`, such as create an entity with it.
// Make sure to call non-async RealityKit methods from the main actor:
await MainActor.run {
let entity = Entity()
entity.components[CollisionComponent.self] = .init(shapes: [shape])
// Note that `mode` can not be set to `.dynamic`. Only `.static` is supported.
entity.components[PhysicsBodyComponent.self] = .init(massProperties: .default,
material: nil,
mode: .static)
// ...
}
}
```
- Parameters:
- meshAnchor: The mesh anchor which will be used for the collision shape. This anchor needs to have
`meshAnchor.geometry.faces.primitiveType == ARGeometryPrimitiveTypeTriangle`.
- Returns: The new shape.
get · iOS 18.0+edgeInsets
TypeScriptget edgeInsets(): { top: number; left: number; bottom: number; right: number }
Swift declarationvar edgeInsets: TextComponent.EdgeInsets { get set }
set · iOS 18.0+edgeInsets
TypeScriptset edgeInsets(value: { top: number; left: number; bottom: number; right: number })
Swift declarationvar edgeInsets: TextComponent.EdgeInsets { get set }
init · iOS 18.0+init
TypeScriptstatic initColorApplyPostProcessToneMap(color: _UIKit_UIColor, applyPostProcessToneMap: boolean): _RealityFoundation_UnlitMaterial
Swift declarationinit(color: UIColor, applyPostProcessToneMap: Bool)
Creates an UnlitMaterial with the given color and tone mapping setting
init · iOS 13.0+init
TypeScriptstatic initColor(color: _UIKit_UIColor): _RealityFoundation_UnlitMaterial
Swift declarationinit(color: UIColor)
Creates an unlit material with the given base color.
- Parameters:
- color: The base color for the new material.
- Note: The blending mode of `UnlitMaterial` materials should be configured explicitly with the
``UnlitMaterial/blending-swift.property`` property for transparent or translucent surfaces. The
`opaque` mode is used when unset.
get · iOS 13.0+ · Deprecated in iOS 15.0baseColor
TypeScriptget baseColor(): MaterialColorParameter
Swift declarationvar baseColor: MaterialColorParameter { get set }
The base color of the material.
set · iOS 13.0+ · Deprecated in iOS 15.0baseColor
TypeScriptset baseColor(value: MaterialColorParameter)
Swift declarationvar baseColor: MaterialColorParameter { get set }
The base color of the material.
get · iOS 13.0+ · Deprecated in iOS 15.0tintColor
TypeScriptget tintColor(): _UIKit_UIColor
Swift declarationvar tintColor: UIColor { get set }
A tint color applied to the base color.
set · iOS 13.0+ · Deprecated in iOS 15.0tintColor
TypeScriptset tintColor(value: _UIKit_UIColor)
Swift declarationvar tintColor: UIColor { get set }
A tint color applied to the base color.
init · iOS 15.0+init
TypeScriptstatic init(color?: _UIKit_UIColor, texture?: (_RealityFoundation_CustomMaterial_CustomMaterialTexture) | null): _RealityFoundation_CustomMaterial_EmissiveColor
Swift declarationinit(color: UIColor = .black, texture: CustomMaterial.Texture? = nil)
Creates a color of emitted light in macOS.
- Parameters:
- color: The color of the emitted light. Defaults to black.
- texture: An optional UV-mapped image texture.
get · iOS 15.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: UIColor { get set }
set · iOS 15.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: UIColor { get set }
init · iOS 15.0+init
TypeScriptstatic init(tint?: _UIKit_UIColor, texture?: (_RealityFoundation_CustomMaterial_CustomMaterialTexture) | null): _RealityFoundation_CustomMaterial_BaseColor
Swift declarationinit(tint: UIColor = .white, texture: CustomMaterial.Texture? = nil)
Creates a base color object from a color or texture on macOS.
This initializer creates a new object from a color or image texture, or
from both. If you don’t provide a `tint` color, `tint` defaults to
white.
Both tint and texture are available to use in your surface shader
function, but RealityKit doesn’t automatically use them to render the
entity. Your surface shader calculates the final base color value for
each pixel and assigns it by calling
`params.surface().set_base_color()`.
For more information on creating custom materials and writing shader
functions, see
<doc:modifying-realitykit-rendering-using-custom-materials>.
- Parameters:
- tint: The tint color. Defaults to white.
- texture: An optional image texture.
get · iOS 15.0+tint
TypeScriptget tint(): _UIKit_UIColor
Swift declarationvar tint: UIColor { get set }
set · iOS 15.0+tint
TypeScriptset tint(value: _UIKit_UIColor)
Swift declarationvar tint: UIColor { get set }
init · iOS 13.0+init
TypeScriptstatic init(color: _UIKit_UIColor, roughness: _RealityFoundation_MaterialScalarParameter, isMetallic: boolean): _RealityFoundation_SimpleMaterial
Swift declarationinit(color: SimpleMaterial.Color, roughness: MaterialScalarParameter = 0.0, isMetallic: Bool)
Creates a simple material with specific characteristics in macOS.
- Parameters:
- color: The color of the material.
- roughness: The roughness of the material.
- isMetallic: A Boolean indicating whether the material should have a
metallic appearance.
get · iOS 13.0+ · Deprecated in iOS 15.0baseColor
TypeScriptget baseColor(): MaterialColorParameter
Swift declarationvar baseColor: MaterialColorParameter { get set }
The base color of the material.
set · iOS 13.0+ · Deprecated in iOS 15.0baseColor
TypeScriptset baseColor(value: MaterialColorParameter)
Swift declarationvar baseColor: MaterialColorParameter { get set }
The base color of the material.
get · iOS 13.0+ · Deprecated in iOS 15.0tintColor
TypeScriptget tintColor(): _UIKit_UIColor
Swift declarationvar tintColor: UIColor { get set }
A tint color applied to the base color in macOS.
set · iOS 13.0+ · Deprecated in iOS 15.0tintColor
TypeScriptset tintColor(value: _UIKit_UIColor)
Swift declarationvar tintColor: UIColor { get set }
A tint color applied to the base color in macOS.
static · iOS 15.0+load
TypeScriptstatic loadNamedInOptions(name: string, bundle: (_Foundation_Bundle) | null, options: _RealityFoundation_TextureResource_CreateOptions): Promise<_RealityFoundation_TextureResource>
Swift declaration@MainActor @preconcurrency static func load(named name: String, in bundle: Bundle? = nil, options: TextureResource.CreateOptions) throws -> TextureResource
Returns a texture resource by synchronously loading it from a bundle with options.
Loading a ``TextureResource`` with this method blocks the main actor because it’s synchronous, so only call it from a command-line application.
The method can stall a regular app, which makes it visibly hitch, and the system terminates an app if its UI becomes unresponsive.
See ``init(named:in:)`` for an example that demonstrates how to safely load content.
This method loads the image that the `URL` specifies, and creates a texture
resource from it.
The method blocks until it finishes loading the image and creating
the texture resource.
RealityKit automatically creates a
resource name based on the `name` and `bundle`
values.
RealityKit uses the resource name to identify resources, and to match
texture resources between networked peers. Specify a unique name for
each texture resource you load or generate.
- Parameters:
- name: The name of the resource. The filename extension is optional.
- bundle: The bundle to search for the resource. Use `nil` to indicate the app’s bundle.
- options: Configurable options that affect texture loading.
- Returns: The loaded resource.
static · iOS 13.0+load
TypeScriptstatic loadNamedIn(name: string, bundle?: (_Foundation_Bundle) | null): Promise<_RealityFoundation_TextureResource>
Swift declaration@MainActor @preconcurrency static func load(named name: String, in bundle: Bundle? = nil) throws -> TextureResource
Returns a texture resource by synchronously loading it from a bundle.
Loading a ``TextureResource`` with this method blocks the main actor because it’s synchronous, so only call it from a command-line application.
The method can stall a regular app, which makes it visibly hitch, and the system terminates an app if its UI becomes unresponsive.
See ``init(named:in:)`` for an example that demonstrates how to safely load content.
This method loads the image that the `URL` specifies, and creates a texture
resource from it. The method blocks until it finishes loading the image and creating
the texture resource.
RealityKit automatically creates a
resource name based on the `name` and `bundle`
values.
RealityKit uses the resource name to identify texture resources, and
to match texture resources between networked peers. Specify a
unique resource name for each texture resource you load or generate.
- Parameters:
- name: The name of the resource. The filename extension is optional.
- bundle: The bundle to search for the resource. Use `nil` to indicate
the app’s bundle.
- Returns: The loaded resource.
init · iOS 18.0+init
TypeScriptstatic initNamedInOptions(name: string, bundle: (_Foundation_Bundle) | null, options: _RealityFoundation_TextureResource_CreateOptions): Promise<_RealityFoundation_TextureResource>
Swift declaration@MainActor @preconcurrency convenience init(named name: String, in bundle: Bundle? = nil, options: TextureResource.CreateOptions) async throws
Asynchronously loads a texture resource from a bundle with options.
RealityKit automatically creates a resource name for the texture
resource based on the values of `name` and `bundle`. RealityKit uses the
resource name to identify resources, and to match texture resources
between networked peers. Specify a unique name for each texture resource
you load or generate.
See ``init(named:in:)`` for an example of optimally loading textures with
other content.
- Parameters:
- name: The name of the resource. The filename extension is optional.
- bundle: The bundle to search for the resource. Use `nil` to indicate the app’s bundle.
- options: Configuration options for texture creation.
init · iOS 18.0+init
TypeScriptstatic initNamedIn(name: string, bundle?: (_Foundation_Bundle) | null): Promise<_RealityFoundation_TextureResource>
Swift declaration@MainActor @preconcurrency convenience init(named name: String, in bundle: Bundle? = nil) async throws
Asynchronously loads a texture resource from a bundle.
RealityKit automatically creates a resource name for the texture
resource based on the values of `name` and `bundle`. RealityKit uses the
resource name to identify resources, and to match texture resources
between networked peers. Specify a unique name for each texture resource
you load or generate.
Load textures concurrently with other content for optimal load times without
causing your app to hitch.
```swift
struct SomeRealityView: View {
var body: some View {
RealityView { content in
// Begin loading the texture.
async let textureA = try? TextureResource(named:"textureA.jpg")
// Load the scene.
guard let rootEntity = try? await Entity(named: "SceneA", in: realityKitContentBundle) else {
return
}
// Wait for the texture to finish loading.
guard let textureA = await textureA else {
return
}
// Create and assign a material that uses the texture to a model entity.
if let entityA = rootEntity.findEntity(named: "ModelA") as? ModelEntity {
var material = PhysicallyBasedMaterial()
material.baseColor = PhysicallyBasedMaterial.BaseColor(tint: .white,
texture: .init(textureA))
entityA.model?.materials[0] = material
}
content.add(rootEntity)
}
}
}
```
- Parameters:
- name: The name of the resource. The filename extension is optional.
- bundle: The bundle to search for the resource. Use `nil` to indicate
the app’s bundle.
static · iOS 15.0+ · Deprecated in iOS 18.0loadAsync
TypeScriptstatic loadAsyncNamedInOptions(name: string, bundle: (_Foundation_Bundle) | null, options: _RealityFoundation_TextureResource_CreateOptions): Promise<_RealityFoundation_LoadRequest<_RealityFoundation_TextureResource>>
Swift declaration@MainActor @preconcurrency static func loadAsync(named name: String, in bundle: Bundle? = nil, options: TextureResource.CreateOptions) -> LoadRequest<TextureResource>
Returns a load request that creates a texture resource by asynchronously loading it from a bundle with options.
RealityKit automatically creates a resource name for the texture
resource based on the values of `name` and `bundle`. RealityKit uses the
resource name to identify resources, and to match texture resources
between networked peers. Specify a unique name for each texture resource
you load or generate.
See ``init(named:in:)`` for an example of optimally loading textures with
other content.
- Parameters:
- name: The name of the resource. The filename extension is optional.
- bundle: The bundle to search for the resource. Use `nil` to indicate the app’s bundle.
- options: Configuration options for texture creation.
- Returns: A load operation that publishes the resource.
static · iOS 13.0+ · Deprecated in iOS 18.0loadAsync
TypeScriptstatic loadAsyncNamedIn(name: string, bundle?: (_Foundation_Bundle) | null): Promise<_RealityFoundation_LoadRequest<_RealityFoundation_TextureResource>>
Swift declaration@MainActor @preconcurrency static func loadAsync(named name: String, in bundle: Bundle? = nil) -> LoadRequest<TextureResource>
Returns a load request that creates a texture resource by asynchronously loading it from a bundle.
RealityKit automatically creates a resource name for the texture
resource based on the values of `name` and `bundle`. RealityKit uses the
resource name to identify resources, and to match texture resources
between networked peers. Specify a unique name for each texture resource
you load or generate.
See ``init(named:in:)`` for an example of optimally loading textures with
other content.
- Parameters:
- name: The name of the resource. The filename extension is optional.
- bundle: The bundle to search for the resource. Use `nil` to indicate
the app’s bundle.
- Returns: A load operation that publishes the resource.
init · iOS 13.0+init
TypeScriptstatic init(anchor: _ARKit_ARAnchor): _RealityFoundation_AnchoringComponent
Swift declarationinit(_ anchor: ARAnchor)
Creates an anchoring component with the given AR anchor.
- Parameters:
- anchor: An existing AR anchor to use.
get · iOS 18.0+colorValue
TypeScriptget colorValue(): (_UIKit_UIColor) | null
Swift declarationvar colorValue: UIColor? { get }
static · iOS 18.0+color
TypeScriptstatic color(color: _UIKit_UIColor): _RealityFoundation_MaterialParameters_Value
Swift declarationstatic func color(_ color: UIColor) -> MaterialParameters.Value
init · iOS 18.0+init
TypeScriptstatic initColorIntensityInnerAngleInDegreesOuterAngleInDegreesAttenuationRadiusAttenuationFalloffExponent(color?: _UIKit_UIColor, intensity?: number, innerAngleInDegrees?: number, outerAngleInDegrees?: number, attenuationRadius?: number, attenuationFalloffExponent?: number): _RealityFoundation_SpotLightComponent
Swift declarationinit(color: SpotLightComponent.Color = .white, intensity: Float = 6740.94, innerAngleInDegrees: Float = 45.0, outerAngleInDegrees: Float = 60.0, attenuationRadius: Float = 10.0, attenuationFalloffExponent: Float = 2.0)
Creates a spotlight with the given parameters.
- Parameters:
- color: The color of the light.
- intensity: The light's brightness.
- innerAngleInDegrees: The angle of the cone that emits light at full intensity, in degrees.
- outerAngleInDegrees: The angle of the cone beyond which the spotlight's intensity is zero.
- attenuationRadius: The distance from the light source where its intensity reaches zero.
Any objects at or beyond this distance do not receive illumination.
- attenuationFalloffExponent: An exponent value for the light's intensity falloff-transition curve.
init · iOS 13.0+init
TypeScriptstatic initColorIntensityInnerAngleInDegreesOuterAngleInDegreesAttenuationRadius(color?: _UIKit_UIColor, intensity?: number, innerAngleInDegrees?: number, outerAngleInDegrees?: number, attenuationRadius?: number): _RealityFoundation_SpotLightComponent
Swift declarationinit(color: SpotLightComponent.Color = .white, intensity: Float = 6740.94, innerAngleInDegrees: Float = 45.0, outerAngleInDegrees: Float = 60.0, attenuationRadius: Float = 10.0)
Creates a spotlight with the given parameters.
- Parameters:
- color: The color of the light.
- intensity: The light's brightness.
- innerAngleInDegrees: The angle of the cone that emits light at full intensity, in degrees.
- outerAngleInDegrees: The angle of the cone beyond which the spotlight's intensity is zero.
- attenuationRadius: The distance from the light source where its intensity reaches zero.
Any objects at or beyond this distance do not receive illumination.
get · iOS 13.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: SpotLightComponent.Color { get set }
A color for the spotlight.
set · iOS 13.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: SpotLightComponent.Color { get set }
A color for the spotlight.
init · iOS 18.0+init
TypeScriptstatic initColorIntensityAttenuationRadiusAttenuationFalloffExponent(color?: _UIKit_UIColor, intensity?: number, attenuationRadius?: number, attenuationFalloffExponent?: number): _RealityFoundation_PointLightComponent
Swift declarationinit(color: PointLightComponent.Color = .white, intensity: Float = 26963.76, attenuationRadius: Float = 10.0, attenuationFalloffExponent: Float = 2.0)
Creates a point light component with a configuration.
- Parameters:
- color: The color of the light.
- intensity: The intensity of the light in lumens.
- attenuationRadius: The distance from the light source where its intensity reaches zero.
Any objects at or beyond this distance do not receive illumination.
- attenuationFalloffExponent: An exponent value for the light's intensity falloff-transition curve.
init · iOS 13.0+init
TypeScriptstatic initColorIntensityAttenuationRadius(color?: _UIKit_UIColor, intensity?: number, attenuationRadius?: number): _RealityFoundation_PointLightComponent
Swift declarationinit(color: PointLightComponent.Color = .white, intensity: Float = 26963.76, attenuationRadius: Float = 10.0)
Creates a point light component with a configuration.
- Parameters:
- color: The color of the light.
- intensity: The intensity of the light in lumens.
- attenuationRadius: The distance from the light source where its intensity reaches zero.
Any objects at or beyond this distance do not receive illumination.
get · iOS 13.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: PointLightComponent.Color { get set }
A color for the point light.
set · iOS 13.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: PointLightComponent.Color { get set }
A color for the point light.
init · iOS 18.0+init
TypeScriptstatic initColorStrengthOpacityFunction(color: (_UIKit_UIColor) | null, strength: number, opacityFunction: _RealityFoundation_HoverEffectComponent_OpacityFunction): _RealityFoundation_HoverEffectComponent_HighlightHoverEffectStyle
Swift declarationinit(color: UIColor? = nil, strength: Float = 1.0, opacityFunction: HoverEffectComponent.OpacityFunction)
Creates a new highlight effect with a color and strength.
init · iOS 18.0+init
TypeScriptstatic initColorStrength(color?: (_UIKit_UIColor) | null, strength?: number): _RealityFoundation_HoverEffectComponent_HighlightHoverEffectStyle
Swift declarationinit(color: UIColor? = nil, strength: Float = 1.0)
Creates a new highlight effect with a color and strength.
get · iOS 18.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: UIColor { get set }
The color tint for the highlight hover effect.
set · iOS 18.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: UIColor { get set }
The color tint for the highlight hover effect.
init · iOS 18.0+init
TypeScriptstatic initColorStrengthOpacityFunction(color: (_UIKit_UIColor) | null, strength: number, opacityFunction: _RealityFoundation_HoverEffectComponent_OpacityFunction): _RealityFoundation_HoverEffectComponent_SpotlightHoverEffectStyle
Swift declarationinit(color: UIColor? = nil, strength: Float = 1.0, opacityFunction: HoverEffectComponent.OpacityFunction)
Creates a new spotlight effect with a color and strength.
init · iOS 18.0+init
TypeScriptstatic initColorStrength(color?: (_UIKit_UIColor) | null, strength?: number): _RealityFoundation_HoverEffectComponent_SpotlightHoverEffectStyle
Swift declarationinit(color: UIColor? = nil, strength: Float = 1.0)
Creates a new spotlight effect with a color and strength.
get · iOS 18.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: UIColor { get set }
The color tint for the spotlight hover effect.
set · iOS 18.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: UIColor { get set }
The color tint for the spotlight hover effect.
get · iOS 17.0+customRotors
TypeScriptget customRotors(): Array<AccessibilityComponent_RotorType>
Swift declarationvar customRotors: [AccessibilityComponent.RotorType] { get set }
An array of supported rotors.
set · iOS 17.0+customRotors
TypeScriptset customRotors(value: Array<AccessibilityComponent_RotorType>)
Swift declarationvar customRotors: [AccessibilityComponent.RotorType] { get set }
An array of supported rotors.
get · iOS 17.0+traits
TypeScriptget traits(): _UIKit_UIAccessibilityTraits
Swift declarationvar traits: UIAccessibilityTraits { get set }
The combination of accessibility traits that best characterize the entity.
set · iOS 17.0+traits
TypeScriptset traits(value: _UIKit_UIAccessibilityTraits)
Swift declarationvar traits: UIAccessibilityTraits { get set }
The combination of accessibility traits that best characterize the entity.
init · iOS 15.0+init
TypeScriptstatic init(tint?: _UIKit_UIColor, texture?: (_RealityFoundation_MaterialParameters_Texture) | null): _RealityFoundation_PhysicallyBasedMaterial_SheenColor
Swift declarationinit(tint: UIColor = .white, texture: MaterialParameters.Texture? = nil)
Creates a sheen color in macOS.
This initializer creates an object from a color, an image texture, or
from both. If you don’t provide a `tint` color, `tint` defaults to
white.
If you specify `texture`, RealityKit calculates the final sheen color
for the entity by UV-mapping `texture` onto the entity and then
multiplying the color at any given pixel by `tint`. If `tint` is white,
RealityKit uses the texture untinted.
If you don’t specify `texture`, then RealityKit uses `tint` as the
entity’s sheen color.
- Parameters:
- tint: The tint color.
- texture: The optional image texture.
get · iOS 15.0+tint
TypeScriptget tint(): _UIKit_UIColor
Swift declarationvar tint: UIColor { get set }
set · iOS 15.0+tint
TypeScriptset tint(value: _UIKit_UIColor)
Swift declarationvar tint: UIColor { get set }
init · iOS 15.0+init
TypeScriptstatic init(color?: _UIKit_UIColor, texture?: (_RealityFoundation_MaterialParameters_Texture) | null): _RealityFoundation_PhysicallyBasedMaterial_EmissiveColor
Swift declarationinit(color: UIColor = .black, texture: MaterialParameters.Texture? = nil)
Creates a color of emitted light in iOS.
This initializer creates an object from a color, an image texture, or
from both. The `color` property defaults to black, which results in no
light emissions. With custom materials, `color` and `texture` are
available as inputs in your surface shader, but your surface shader must
call `params.surface().set_emissive_color()`, otherwise RealityKit
renders no light emission.
The following Metal code demonstrates how to replicate the emissive
behavior of ``PhysicallyBasedMaterial`` in your surface shader code:
```swift
// Retrieve the emissive color tint from the CustomMaterial.
half3 emissiveColorTint = (half3)params.material_constants()
.emissive_color_tint();
// Retrieve the primary texture coordinates.
float2 uv = params.geometry().uv0();
// Flip the UV coordinate’s y-axis. You only need to do this
// for models you load from USDZ or .reality files.
uv.y = 1.0 - uv.y;
auto tex = params.textures();
half3 color = (half3)tex.emissive_color()
.sample(textureSampler, uv).rgb;
// Multiply the tint and the sampled value from the texture,
// and assign the result to the shader's emissive color
// property.
color *= emissiveColorTint;
params.surface().set_emissive_color(color);
```
- Note: Unlike ``PhysicallyBasedMaterial``, ``CustomMaterial`` has no
``PhysicallyBasedMaterial/emissiveIntensity`` value. If you need to pass
an emissive intensity value to your surface shader, use the
``CustomMaterial/custom-swift.property`` property or another unused
attribute property.
- Parameters:
- color: The color of the emitted light. Defaults to black.
- texture: An optional UV-mapped image texture.
get · iOS 15.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: UIColor { get set }
set · iOS 15.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: UIColor { get set }
init · iOS 15.0+init
TypeScriptstatic init(tint?: _UIKit_UIColor, texture?: (_RealityFoundation_MaterialParameters_Texture) | null): _RealityFoundation_PhysicallyBasedMaterial_BaseColor
Swift declarationinit(tint: UIColor = .white, texture: MaterialParameters.Texture? = nil)
Creates a base color object from a color or texture on macOS.
This initializer creates a new instance from a color or image texture,
or from both. If you don’t provide a `tint` color, `tint` defaults to
white.
If you specify `texture`, RealityKit calculates the final base color for
the entity by UV-mapping `texture` onto the entity and then multiplying
the color at any given pixel by `tint`. If `tint` is white, RealityKit
renders the textured untinted.
If you don’t specify a texture, RealityKit uses `tint` as the entity’s
base color.
- Parameters:
- tint: The tint color. Defaults to white.
- texture: An optional image texture.
get · iOS 15.0+tint
TypeScriptget tint(): _UIKit_UIColor
Swift declarationvar tint: UIColor { get set }
set · iOS 15.0+tint
TypeScriptset tint(value: _UIKit_UIColor)
Swift declarationvar tint: UIColor { get set }
get · iOS 18.0+timing
TypeScriptget timing(): ParticleEmitterComponent_Timing
Swift declarationvar timing: ParticleEmitterComponent.Timing { get set }
Defines the Emitter timing method.
set · iOS 18.0+timing
TypeScriptset timing(value: ParticleEmitterComponent_Timing)
Swift declarationvar timing: ParticleEmitterComponent.Timing { get set }
Defines the Emitter timing method.
get · iOS 18.0+color
TypeScriptget color(): ParticleEmitterComponent_ParticleEmitter_ParticleColor
Swift declarationvar color: ParticleEmitterComponent.ParticleEmitter.ParticleColor { get set }
The color of particles.
set · iOS 18.0+color
TypeScriptset color(value: ParticleEmitterComponent_ParticleEmitter_ParticleColor)
Swift declarationvar color: ParticleEmitterComponent.ParticleEmitter.ParticleColor { get set }
The color of particles.
init · iOS 13.0+init
TypeScriptstatic init(color?: _UIKit_UIColor, intensity?: number, isRealWorldProxy?: boolean): _RealityFoundation_DirectionalLightComponent
Swift declarationinit(color: DirectionalLightComponent.Color = .white, intensity: Float = 2145.7078, isRealWorldProxy: Bool = false)
Creates a directional light with a configuration.
- Parameters:
- color: A color for the light.
- intensity: The intensity of the light, measured in lumen per square
meter.
- isRealWorldProxy: A Boolean that you use to control whether the light
operates as a proxy for a real-world light.
get · iOS 13.0+color
TypeScriptget color(): _UIKit_UIColor
Swift declarationvar color: DirectionalLightComponent.Color { get set }
A color for the directional light.
set · iOS 13.0+color
TypeScriptset color(value: _UIKit_UIColor)
Swift declarationvar color: DirectionalLightComponent.Color { get set }
A color for the directional light.
get · iOS 17.0+accessibilityValue
TypeScriptget accessibilityValue(): Promise<(_Foundation_LocalizedStringResource) | null>
Swift declaration@MainActor @preconcurrency var accessibilityValue: LocalizedStringResource? { get set }
A localized string key that represents the current value of the entity.
set · iOS 17.0+accessibilityValue
TypeScriptsetAccessibilityValue(value?: (_Foundation_LocalizedStringResource) | null): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilityValue: LocalizedStringResource? { get set }
A localized string key that represents the current value of the entity.
get · iOS 17.0+accessibilityTraits
TypeScriptget accessibilityTraits(): Promise<_UIKit_UIAccessibilityTraits>
Swift declaration@MainActor @preconcurrency var accessibilityTraits: UIAccessibilityTraits { get set }
The combination of accessibility traits that best characterize the entity.
set · iOS 17.0+accessibilityTraits
TypeScriptsetAccessibilityTraits(value: _UIKit_UIAccessibilityTraits): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilityTraits: UIAccessibilityTraits { get set }
The combination of accessibility traits that best characterize the entity.
get · iOS 17.0+accessibilityLabelKey
TypeScriptget accessibilityLabelKey(): Promise<(_Foundation_LocalizedStringResource) | null>
Swift declaration@MainActor @preconcurrency var accessibilityLabelKey: LocalizedStringResource? { get set }
A succinct label that identifies the entity, in a localized string key.
set · iOS 17.0+accessibilityLabelKey
TypeScriptsetAccessibilityLabelKey(value?: (_Foundation_LocalizedStringResource) | null): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilityLabelKey: LocalizedStringResource? { get set }
A succinct label that identifies the entity, in a localized string key.
get · iOS 17.0+accessibilityCustomRotors
TypeScriptget accessibilityCustomRotors(): Promise<Array<AccessibilityComponent_RotorType>>
Swift declaration@MainActor @preconcurrency var accessibilityCustomRotors: [AccessibilityComponent.RotorType] { get set }
An array of supported rotors.
set · iOS 17.0+accessibilityCustomRotors
TypeScriptsetAccessibilityCustomRotors(value: Array<AccessibilityComponent_RotorType>): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilityCustomRotors: [AccessibilityComponent.RotorType] { get set }
An array of supported rotors.
get · iOS 17.0+accessibilityCustomActions
TypeScriptget accessibilityCustomActions(): Promise<Array<_Foundation_LocalizedStringResource>>
Swift declaration@MainActor @preconcurrency var accessibilityCustomActions: [LocalizedStringResource] { get set }
An array of custom actions supported by the entity, identified by their localized string key.
set · iOS 17.0+accessibilityCustomActions
TypeScriptsetAccessibilityCustomActions(value: Array<_Foundation_LocalizedStringResource>): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilityCustomActions: [LocalizedStringResource] { get set }
An array of custom actions supported by the entity, identified by their localized string key.
get · iOS 17.0+accessibilityCustomContent
TypeScriptget accessibilityCustomContent(): Promise<Array<_RealityFoundation_AccessibilityComponent_CustomContent>>
Swift declaration@MainActor @preconcurrency var accessibilityCustomContent: [AccessibilityComponent.CustomContent] { get set }
The Custom Content API is useful for delivering accessibility information from complex data sets to your users in measured portions.
Using this API allows you to leverage assistive technologies to present only the accessible content your app’s users need, when they need it.
set · iOS 17.0+accessibilityCustomContent
TypeScriptsetAccessibilityCustomContent(value: Array<_RealityFoundation_AccessibilityComponent_CustomContent>): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilityCustomContent: [AccessibilityComponent.CustomContent] { get set }
The Custom Content API is useful for delivering accessibility information from complex data sets to your users in measured portions.
Using this API allows you to leverage assistive technologies to present only the accessible content your app’s users need, when they need it.
get · iOS 17.0+accessibilitySystemActions
TypeScriptget accessibilitySystemActions(): Promise<_RealityFoundation_AccessibilityComponent_SupportedActions>
Swift declaration@MainActor @preconcurrency var accessibilitySystemActions: AccessibilityComponent.SupportedActions { get set }
The set of supported accessibility actions.
set · iOS 17.0+accessibilitySystemActions
TypeScriptsetAccessibilitySystemActions(value: _RealityFoundation_AccessibilityComponent_SupportedActions): Promise<void>
Swift declaration@MainActor @preconcurrency var accessibilitySystemActions: AccessibilityComponent.SupportedActions { get set }
The set of supported accessibility actions.