One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

MeshResource

class · iOS 13.0+ · SDK 27.1

@MainActor @preconcurrency class MeshResource

A high-level representation of a collection of vertices and edges that define a shape.

Members (25)

get · iOS 18.0+

lowLevelMesh

TypeScript
get lowLevelMesh(): Promise<(LowLevelMesh) | null>
Swift declaration
@MainActor @preconcurrency var lowLevelMesh: LowLevelMesh? { get }

The low-level mesh that this mesh is built from, if any. If this mesh is not built from a ``LowLevelMesh``, it returns nil.

static · iOS 13.0+

generateBox

TypeScript
static generateBoxSizeCornerRadius(size: number, cornerRadius?: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateBox(size: Float, cornerRadius: Float = 0) -> MeshResource

Creates a box mesh from a length for the box's width, height, and depth, and a radius for the corners. - Parameters: - size: The length of the box's width, height, and depth, in meters. - cornerRadius: The radius of each corner's circular arc, in meters. Values for `cornerRadius` can be, at most, equal to `size / 2.0`. For example, if the box's dimensions are `5.0` x `5.0` x `5.0`, the corner radius needs to be in the range `[0.0, 2.5]`. The method centers the box at the entity’s origin and aligns the box's faces with the coordinate system's axes. > Note: The method clamps `cornerRadius` so that it doesn't exceed half the length of the box's smallest dimension.

static · iOS 13.0+

generateBox

TypeScript
static generateBoxSizeCornerRadius34756(size: SDKHandle, cornerRadius?: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateBox(size: SIMD3<Float>, cornerRadius: Float = 0) -> MeshResource

Creates a box mesh from a vector of three scalar values that represent width, height, and depth, respectively, and a radius for the corners. - Parameters: - size: The length of the box's width, height, and depth, in meters, along the x-, y-, and z-axis, respectively. - cornerRadius: The radius of each corner's circular arc, in meters. Values for `cornerRadius` can be, at most, equal to `min(size.x, size.y, size.z) / 2.0`. For example, if the box's dimensions are `3.0` x `4.0` x `5.0`, the corner radius needs to be in the range `[0.0, 1.5]`. The method centers the box at the entity’s origin and aligns the box's faces with the coordinate system's axes. > Note: The method clamps `cornerRadius` so that it doesn't exceed half the length of the box's smallest dimension.

static · iOS 18.0+

generateBox

TypeScript
static generateBoxSizeMajorCornerRadiusMinorCornerRadius(size: SDKHandle, majorCornerRadius?: number, minorCornerRadius?: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateBox(size: SIMD3<Float>, majorCornerRadius: Float = 0.2, minorCornerRadius: Float = 0.05) -> MeshResource

Creates a box mesh from a vector of three scalar values that represent width, height, and depth, respectively, and radii for the corners. - Parameters: - size: The length of the box's width, height, and depth, in meters, along the x-, y-, and z-axis, respectively. - majorCornerRadius: The radius of each corner's circular arc, in meters, orthogonal to the z-axis. - minorCornerRadius: The radius of each corner's circular arc, in meters, orthogonal to the x-axis. The method centers the box at the entity’s origin and aligns the box's faces with the coordinate system's axes.

static · iOS 13.0+

generateBox

TypeScript
static generateBoxWidthHeightDepthCornerRadiusSplitFaces(width: number, height: number, depth: number, cornerRadius?: number, splitFaces?: boolean): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateBox(width: Float, height: Float, depth: Float, cornerRadius: Float = 0, splitFaces: Bool = false) -> MeshResource

Creates a box mesh from a width, height, depth, a radius for the corners, and a Boolean option that splits faces. - Parameters: - width: The length of the box's width, in meters, along the x-axis. - height: The length of the box's height, in meters, along the y-axis. - depth: The length of the box's depth, in meters, along the z-axis. - cornerRadius: The radius of each corner's circular arc, in meters. Values for `cornerRadius` can be, at most, equal to the smallest value of the `width`, `height`, and `depth` parameters. For example, if the box's dimensions are `3.0` x `4.0` x `5.0`, the corner radius needs to be in the range `[0.0, 1.5]`. - splitFaces: A Boolean value that indicates whether you can assign up to six separate materials, one for each face. If `false`, you can only assign one material for all six faces. The method centers the box at the entity’s origin and aligns the box's faces with the coordinate system's axes. > Note: The method clamps `cornerRadius` so that it doesn't exceed half the length of the box's smallest dimension.

static · iOS 18.0+

generateCone

TypeScript
static generateCone(height: number, radius: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateCone(height: Float, radius: Float) -> MeshResource

Creates a new cone mesh with the specified dimensions. - Parameters: - height: The height of the cone in meters [m]. - radius: The radius of the cone in meters [m]. The cone is centered at the local origin.

method · iOS 15.0+ · Deprecated in iOS 18.0

replaceAsync

TypeScript
replaceAsync(content: MeshResource_Contents): Promise<LoadRequest<MeshResource>>
Swift declaration
@MainActor @preconcurrency func replaceAsync(with content: MeshResource.Contents) -> LoadRequest<MeshResource>

Replace the contents of this mesh resource asynchronously. - Note: The contents of the modified mesh resource will not be synced between network clients.

static · iOS 15.0+ · Deprecated in iOS 18.0

generateAsync

TypeScript
static generateAsyncFrom(content: MeshResource_Contents): Promise<LoadRequest<MeshResource>>
Swift declaration
@MainActor @preconcurrency static func generateAsync(from content: MeshResource.Contents) -> LoadRequest<MeshResource>

Create a mesh resource from contents asynchronously.

static · iOS 15.0+ · Deprecated in iOS 18.0

generateAsync

TypeScript
static generateAsyncFrom36111(descriptors: Array<MeshDescriptor>): Promise<LoadRequest<MeshResource>>
Swift declaration
@MainActor @preconcurrency static func generateAsync(from descriptors: [MeshDescriptor]) -> LoadRequest<MeshResource>

Create a mesh resource from a list of mesh descriptors asynchronously.

static · iOS 13.0+

generatePlane

TypeScript
static generatePlaneWidthDepthCornerRadius(width: number, depth: number, cornerRadius?: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generatePlane(width: Float, depth: Float, cornerRadius: Float = 0) -> MeshResource

Creates a new rectangle mesh with the specified dimensions in the entity’s xz-plane. The rectangle is centered at the entity’s origin and aligned with its x and y axes. The surface normal points along the y-axis. The depth along the y-axis is 0. - Note: The xz-plane is a plane that aligns with the x and z axes. - Parameters: - width: The width, in meters, of the rectangle along the x-axis. - depth: The depth, in meters, of the rectangle along the z-axis. - cornerRadius: A corner radius in the form of a circular arc, with curvature that transitions abruptly from `0` to `1/r` at the boundary between the edge and the corner. - Returns: The rectangle mesh.

static · iOS 13.0+

generatePlane

TypeScript
static generatePlaneWidthHeightCornerRadius(width: number, height: number, cornerRadius?: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generatePlane(width: Float, height: Float, cornerRadius: Float = 0) -> MeshResource

Creates a new rectangle mesh with the specified dimensions in the entity’s xy-plane. The rectangle is centered at the entity’s origin and aligned with its x and y axes. The surface normal points along the z-axis. The depth along the z-axis is 0. - Note: The xy-plane is a plane that aligns with the x and y axes. - Parameters: - width: The width, in meters, of the rectangle along the x-axis. - height: The height, in meters, of the rectangle along the y-axis. - cornerRadius: A corner radius in the form of a circular arc, with curvature that transitions abruptly from `0` to `1/r` at the boundary between the edge and the corner. - Returns: The rectangle mesh.

method · iOS 26.0+

meshPartIndex

TypeScript
meshPartIndex(modelID: string, partID: string): Promise<(number) | null>
Swift declaration
@MainActor @preconcurrency func meshPartIndex(modelID: String, partID: String) -> Int?

Get the mesh part index for a given model and part identifier. You can use this to resolve string names to part indices for use in ``MeshInstancesComponent``.

static · iOS 13.0+

generateSphere

TypeScript
static generateSphere(radius: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateSphere(radius: Float) -> MeshResource

Creates a new sphere mesh with the specified radius. The sphere is centered at the entity’s origin. - Parameters: - radius: The radius, in meters, of the sphere. - Returns: A sphere mesh.

static · iOS 18.0+

generateCylinder

TypeScript
static generateCylinder(height: number, radius: number): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generateCylinder(height: Float, radius: Float) -> MeshResource

Creates a new cylinder mesh with the specified dimensions. - Parameters: - height: The height of the cylinder in meters [m]. - radius: The radius of the cylinder in meters [m]. The cylinder is centered at the local origin.

get · iOS 13.0+

expectedMaterialCount

TypeScript
get expectedMaterialCount(): Promise<number>
Swift declaration
@MainActor @preconcurrency var expectedMaterialCount: Int { get }

The number of material entries required to render the mesh resource.

init · iOS 18.0+

init

TypeScript
static initShape(resource: ShapeResource): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency convenience init(shape resource: ShapeResource) async

Generates a MeshResource from a ShapeResource. - Parameters: - resource: The ShapeResource which will be used for generating the mesh.

init · iOS 18.0+

init

TypeScript
static initShape58693(resource: ShapeResource): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency convenience init(shape resource: ShapeResource)

Generates a MeshResource from a ShapeResource. - Parameters: - resource: The ShapeResource which will be used for generating the mesh.

get · iOS 13.0+

bounds

TypeScript
get bounds(): Promise<BoundingBox>
Swift declaration
@MainActor @preconcurrency var bounds: BoundingBox { get }

A box that bounds the mesh.

method · iOS 15.0+

replace

TypeScript
replaceWith(content: MeshResource_Contents): Promise<void>
Swift declaration
@MainActor @preconcurrency func replace(with content: MeshResource.Contents) throws

Replace the contents of this mesh resource. - Note: The contents of the modified mesh resource will not be synced between network clients.

method · iOS 18.0+

replace

TypeScript
replaceWith57252(content: MeshResource_Contents): Promise<void>
Swift declaration
nonisolated func replace(with content: MeshResource.Contents) async throws

Replace the contents of this mesh resource asynchronously. - Note: The contents of the modified mesh resource will not be synced between network clients.

get · iOS 15.0+

contents

TypeScript
get contents(): Promise<MeshResource_Contents>
Swift declaration
@MainActor @preconcurrency var contents: MeshResource.Contents { get }

Get the contents of the mesh asset.

static · iOS 15.0+

generate

TypeScript
static generateFrom(content: MeshResource_Contents): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generate(from content: MeshResource.Contents) throws -> MeshResource

Create a mesh resource from contents.

static · iOS 15.0+

generate

TypeScript
static generateFrom7892(descriptors: Array<MeshDescriptor>): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency static func generate(from descriptors: [MeshDescriptor]) throws -> MeshResource

Create a mesh resource from a list of mesh descriptors.

init · iOS 18.0+

init

TypeScript
static initExtrudingTextOptionsExtrusionOptions(string: _Foundation_AttributedString, textOptions?: MeshResource_GenerateTextOptions, extrusionOptions?: MeshResource_ShapeExtrusionOptions): Promise<MeshResource>
Swift declaration
@MainActor @preconcurrency convenience init(extruding string: AttributedString, textOptions: MeshResource.GenerateTextOptions = GenerateTextOptions(), extrusionOptions: MeshResource.ShapeExtrusionOptions = ShapeExtrusionOptions()) throws

Synchronously generates a 3D mesh from a string, with options for text layout and custom extrusions. You can use the method to make a 3D mesh of a string, control the text's layout, chamfers, materials, and how to extrude the shape into 3D. The generated text is scaled at a ratio of 72 points per meter. ![A screenshot of a living room scene with 3D text in the center that reads "Hello, World!", which is primarily a teal color with chamfered, gray edges around the text's faces that face the camera.](meshResource-generateText-extrusion) - Parameters: - string: A string that contains text for the 3D mesh geometry. - textOptions: A configuration for rendering the text in 2D, before extrusion. - extrusionOptions: A configuration for extruding the text in 3D.

init · iOS 18.0+

init

TypeScript
static initExtrudingTextOptionsExtrusionOptions68213(string: _Foundation_AttributedString, textOptions?: MeshResource_GenerateTextOptions, extrusionOptions?: MeshResource_ShapeExtrusionOptions): Promise<MeshResource>
Swift declaration
nonisolated convenience init(extruding string: AttributedString, textOptions: MeshResource.GenerateTextOptions = GenerateTextOptions(), extrusionOptions: MeshResource.ShapeExtrusionOptions = ShapeExtrusionOptions()) async throws

Asynchronously generates a 3D mesh from a string, with options for text layout and custom extrusions. You can use the method to make a 3D mesh of a string, control the text's layout, chamfers, materials, and how to extrude the shape into 3D. The generated text is scaled at a ratio of 72 points per meter. ![A screenshot of a living room scene with 3D text in the center that reads "Hello, World!", which is primarily a teal color with chamfered, gray edges around the text's faces that face the camera.](meshResource-generateText-extrusion) - Parameters: - string: A string that contains text for the 3D mesh geometry. - textOptions: A configuration for rendering the text in 2D, before extrusion. - extrusionOptions: A configuration for extruding the text in 3D.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →