<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/BlendShapeWeightsMapping",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation24BlendShapeWeightsMappingC"
  },
  "title" : "BlendShapeWeightsMapping"
}
-->

# BlendShapeWeightsMapping

A mapping of blend weights to the target meshes that those weights affect.

```
class BlendShapeWeightsMapping
```

## Overview

Use `BlendShapeWeightsMapping` to initialize a [`BlendShapeWeightsComponent`](/documentation/RealityKit/BlendShapeWeightsComponent). You can
initialize it in two different ways:

- Initialize the mapping from a user-provided [`MeshResource`](/documentation/RealityKit/MeshResource), from which the mapping information can
  be generated.  In this case, the number of blend shapes and each blend shape’s weights map exactly
  to the `MeshResource`’s structure.

```swift
if let modelComponent = blendShapeEntity.components[ModelComponent.self] {
    let meshResource = modelComponent.mesh
    let blendShapeWeightsMapping = BlendShapeWeightsMapping(
        meshResource: meshResource)
    blendShapeEntity.components.set(BlendShapeWeightsComponent(
        weightsMapping: blendShapeWeightsMapping))
}
```

- Initialize the mapping from a user-defined blend shape name and list of weight names.  When used to initialize
  a [`BlendShapeWeightsComponent`](/documentation/RealityKit/BlendShapeWeightsComponent), the weight names define which mesh targets map from the
  owning entity’s [`ModelComponent`](/documentation/RealityKit/ModelComponent)’s mesh resource.
  
  RealityKit expects the [`ModelComponent`](/documentation/RealityKit/ModelComponent) to already be assigned to the entity on which the [`BlendShapeWeightsComponent`](/documentation/RealityKit/BlendShapeWeightsComponent)
  resides.  Match the weight names to the weight names found in the [`ModelComponent`](/documentation/RealityKit/ModelComponent)’s mesh resource.
  If a weight name does not match any of the mesh weight names then it is ignored and that weight will have no effect.
  If a weight name in the [`ModelComponent`](/documentation/RealityKit/ModelComponent)’s mesh resource is excluded from the list of weight names, then the
  associated target mesh will not be controllable by any of the provided weights.
  
  Note also that the provided blend shape name can be used to reference the blend shape weights in the
  [`BlendShapeWeightsSet`](/documentation/RealityKit/BlendShapeWeightsSet).

```swift
let weightNames: [String] = [
    "weight0",
    "weight1"
]

let blendShapeWeightsMapping = BlendShapeWeightsMapping(
    blendShapeName: "BlendShape0",
    weightNames: weightNames)

blendShapeEntity.components.set(BlendShapeWeightsComponent(
    weightsMapping: blendShapeWeightsMapping))
```

## Topics

### Initializers

[`init(blendShapeName: String, weightNames: [String])`](/documentation/RealityKit/BlendShapeWeightsMapping/init(blendShapeName:weightNames:))

Creates a mapping that applies the weight names to mesh parts in a
model component.

[`init(meshResource: MeshResource)`](/documentation/RealityKit/BlendShapeWeightsMapping/init(meshResource:))

Creates a mapping from the given MeshResource.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Resource`](/documentation/RealityKit/Resource)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)