Swiftpack.co - tattn/VRMKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by tattn.
tattn/VRMKit 0.6.0
VRM loader and VRM renderer (3D model / gltf)
⭐️ 140
🕓 Yesterday
iOS watchOS
.package(url: "https://github.com/tattn/VRMKit.git", from: "0.6.0")

VRMKit

VRM loader and VRM renderer

demo demo

For "VRM", please refer to this page.

Features

  • ☑ Load VRM file
  • ☑ Render VRM models on SceneKit (experimental)
  • ☑ Face morphing (blend shape)
  • ☑ Bone animation (skin / joint)
  • ☑ Physics (spring bone)

Requirements

  • Swift 5.7+
  • iOS 15.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

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

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

joy
node.setBlendShape(value: 1.0, for: .preset(.joy))
angry
node.setBlendShape(value: 1.0, for: .preset(.angry))
><
node.setBlendShape(value: 1.0, for: .custom("><"))

Bone animation

Humanoid
node.setBlendShape(value: 1.0, for: .preset(.fun))
node.humanoid.node(for: .neck)?.eulerAngles = SCNVector3(0, 0, 20 * CGFloat.pi / 180)
node.humanoid.node(for: .leftShoulder)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180)
node.humanoid.node(for: .rightShoulder)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180)

Read the thumbnail image

let loader = try VRMSceneLoader(named: "model.vrm")
let image = try loader.loadThumbnail()

ToDo

  • ☐ VRM 1.0 support
    • ☑ Decoding VRM 1.0 file
    • ☐ Render an avatar by SceneKit
  • ☐ 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.

Donate

License

VRMKit is released under the MIT license. See LICENSE for details.

Author

Tatsuya Tanaka

Twitter GitHub

GitHub

link
Stars: 140
Last commit: 2 days ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

VRM 1.0 parsing support
2 days ago

What's Changed

New Contributors

Full Changelog: https://github.com/tattn/VRMKit/compare/0.5.0...0.6.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics