https://github.com/tattn/vrmkit
VRM loader and VRM renderer (3D model / gltf)
https://github.com/tattn/vrmkit
3d gltf ios scenekit swift vrm
Last synced: 5 months ago
JSON representation
VRM loader and VRM renderer (3D model / gltf)
- Host: GitHub
- URL: https://github.com/tattn/vrmkit
- Owner: tattn
- License: mit
- Created: 2018-09-12T18:44:03.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-06-15T05:14:50.000Z (12 months ago)
- Last Synced: 2026-01-18T20:57:32.111Z (5 months ago)
- Topics: 3d, gltf, ios, scenekit, swift, vrm
- Language: Swift
- Homepage:
- Size: 21.3 MB
- Stars: 174
- Watchers: 4
- Forks: 32
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
VRMKit
VRM loader and VRM renderer
For "VRM", please refer to [this page](https://dwango.github.io/en/vrm/).
## Features
- [x] Load VRM file
- [x] Render VRM models on RealityKit (experimental)
- [x] Face morphing (blend shape)
- [x] Bone animation (skin / joint)
- [x] Physics (spring bone)
# Requirements
- Swift 6.0+
- iOS 15.0+
- macOS 12.0+
- visionOS 2.0+
- watchOS 8.0+ (Experimental)
# Installation
## Swift Package Manager
You can install this package with Swift Package Manager.
## Carthage & CocoaPods (Deprecated)
If you want to use these package managers, please use https://github.com/tattn/VRMKit/releases/tag/0.4.2
# Usage
## Load VRM
```swift
import VRMKit
let vrm = try VRMLoader().load(named: "model.vrm")
// let vrm = try VRMLoader().load(withUrl: URL(string: "/path/to/model.vrm")!)
// let vrm = try VRMLoader().load(withData: data)
// VRM meta data
vrm.meta.title
vrm.meta.author
// model data
vrm.gltf.jsonData.nodes[0].name
```
## Render VRM
```swift
import RealityKit
import VRMKit
import VRMRealityKit
let loader = try VRMEntityLoader(named: "model.vrm")
let vrmEntity = try loader.loadEntity()
let arView = ARView(frame: .zero, cameraMode: .nonAR, automaticallyConfigureSession: false)
let anchor = AnchorEntity(world: .zero)
anchor.addChild(vrmEntity.entity)
arView.scene.addAnchor(anchor)
```
### Render VRM (SwiftUI)
```swift
import RealityKit
import RealityKitContent
import VRMKit
import VRMRealityKit
import SwiftUI
struct ContentView: View {
var body: some View {
RealityView { content in
let loader = try VRMEntityLoader(named: "model.vrm")
let vrmEntity = try loader.loadEntity()
content.add(vrmEntity.entity)
}
}
}
```
Render VRM (SceneKit) — Deprecated
> Note: VRMSceneKit is deprecated. Use VRMRealityKit instead.
```swift
import VRMKit
import VRMSceneKit
@IBOutlet weak var sceneView: SCNView!
let loader = try VRMSceneLoader(named: "model.vrm")
let scene: VRMScene = try loader.loadScene()
let node: VRMNode = scene.vrmNode
sceneView.scene = scene
```
### Blend shapes

```swift
vrmEntity.setBlendShape(value: 1.0, for: .preset(.joy))
```

```swift
vrmEntity.setBlendShape(value: 1.0, for: .preset(.angry))
```

```swift
vrmEntity.setBlendShape(value: 1.0, for: .custom("><"))
```
### Bone animation

```swift
vrmEntity.setBlendShape(value: 1.0, for: .preset(.fun))
let neckRotation = simd_quatf(angle: 20 * .pi / 180, axis: SIMD3(0, 0, 1))
let shoulderRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1))
vrmEntity.humanoid.node(for: .neck)?.transform.rotation *= neckRotation
vrmEntity.humanoid.node(for: .leftShoulder)?.transform.rotation *= shoulderRotation
vrmEntity.humanoid.node(for: .rightShoulder)?.transform.rotation *= shoulderRotation
```
### Read the thumbnail image
```swift
let loader = try VRMEntityLoader(named: "model.vrm")
let image = try loader.loadThumbnail()
```
# ToDo
- [ ] VRM 1.0 support
- [x] Decoding VRM 1.0 file
- [ ] Render an avatar by RealityKit
- [ ] VRM shaders support
- [ ] Improve rendering quality
- [ ] Animation support
- [ ] VRM editing function
- [ ] GLTF renderer support
# Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
## Support this project
Donating to help me continue working on this project.
[](https://paypal.me/tattn/)
# License
VRMKit is released under the MIT license. See LICENSE for details.
# Author
Tatsuya Tanaka