From 1ca1b074a1ce64616f994d831cf95c95964fbd79 Mon Sep 17 00:00:00 2001 From: tatsuya ogawa Date: Wed, 18 Mar 2026 20:10:07 +0900 Subject: [PATCH 1/4] upper arm --- Example/Example/RealityKitViewController.swift | 14 +++++++------- Example/Example/ViewController.swift | 4 ++-- Example/MacExample/ContentView.swift | 14 +++++++------- Example/VisionExample/ContentView.swift | 14 +++++++------- Example/WatchExample Watch App/ViewModel.swift | 4 ++-- README.md | 6 +++--- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Example/Example/RealityKitViewController.swift b/Example/Example/RealityKitViewController.swift index 739b8a4..f448e04 100644 --- a/Example/Example/RealityKitViewController.swift +++ b/Example/Example/RealityKitViewController.swift @@ -100,19 +100,19 @@ final class RealityKitViewController: UIViewController, UIGestureRecognizerDeleg updateCameraTransform() let neck = vrmEntity.humanoid.node(for: .neck) - let leftShoulder = vrmEntity.humanoid.node(for: .leftShoulder) ?? vrmEntity.humanoid.node(for: .leftUpperArm) - let rightShoulder = vrmEntity.humanoid.node(for: .rightShoulder) ?? vrmEntity.humanoid.node(for: .rightUpperArm) + let leftUpperArm = vrmEntity.humanoid.node(for: .leftUpperArm) + let rightUpperArm = vrmEntity.humanoid.node(for: .rightUpperArm) 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)) + let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) if let neck { neck.transform.rotation = neck.transform.rotation * neckRotation } - if let leftShoulder { - leftShoulder.transform.rotation = leftShoulder.transform.rotation * shoulderRotation + if let leftUpperArm { + leftUpperArm.transform.rotation = leftUpperArm.transform.rotation * upperArmRotation } - if let rightShoulder { - rightShoulder.transform.rotation = rightShoulder.transform.rotation * shoulderRotation + if let rightUpperArm { + rightUpperArm.transform.rotation = rightUpperArm.transform.rotation * upperArmRotation } vrmEntity.setBlendShape(value: 1.0, for: .preset(currentExpression.preset)) diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 1fb4a42..713918b 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -114,8 +114,8 @@ class ViewController: UIViewController { node.setBlendShape(value: 1.0, for: .preset(currentExpression.preset)) 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) + node.humanoid.node(for: .leftUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) + node.humanoid.node(for: .rightUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) node.runAction(SCNAction.repeatForever(SCNAction.sequence([ SCNAction.rotateBy(x: 0, y: -0.5, z: 0, duration: 0.5), diff --git a/Example/MacExample/ContentView.swift b/Example/MacExample/ContentView.swift index 2338b3d..2b8f2d1 100644 --- a/Example/MacExample/ContentView.swift +++ b/Example/MacExample/ContentView.swift @@ -73,19 +73,19 @@ final class ContentViewModel { // Adjust pose let neck = vrmEntity.humanoid.node(for: .neck) - let leftShoulder = vrmEntity.humanoid.node(for: .leftShoulder) ?? vrmEntity.humanoid.node(for: .leftUpperArm) - let rightShoulder = vrmEntity.humanoid.node(for: .rightShoulder) ?? vrmEntity.humanoid.node(for: .rightUpperArm) + let leftUpperArm = vrmEntity.humanoid.node(for: .leftUpperArm) + let rightUpperArm = vrmEntity.humanoid.node(for: .rightUpperArm) 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)) + let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) if let neck { neck.transform.rotation = neck.transform.rotation * neckRotation } - if let leftShoulder { - leftShoulder.transform.rotation = leftShoulder.transform.rotation * shoulderRotation + if let leftUpperArm { + leftUpperArm.transform.rotation = leftUpperArm.transform.rotation * upperArmRotation } - if let rightShoulder { - rightShoulder.transform.rotation = rightShoulder.transform.rotation * shoulderRotation + if let rightUpperArm { + rightUpperArm.transform.rotation = rightUpperArm.transform.rotation * upperArmRotation } vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) diff --git a/Example/VisionExample/ContentView.swift b/Example/VisionExample/ContentView.swift index 7f809b8..25683a0 100644 --- a/Example/VisionExample/ContentView.swift +++ b/Example/VisionExample/ContentView.swift @@ -103,19 +103,19 @@ final class ImmersiveViewModel { // Adjust pose let neck = vrmEntity.humanoid.node(for: .neck) - let leftShoulder = vrmEntity.humanoid.node(for: .leftShoulder) ?? vrmEntity.humanoid.node(for: .leftUpperArm) - let rightShoulder = vrmEntity.humanoid.node(for: .rightShoulder) ?? vrmEntity.humanoid.node(for: .rightUpperArm) + let leftUpperArm = vrmEntity.humanoid.node(for: .leftUpperArm) + let rightUpperArm = vrmEntity.humanoid.node(for: .rightUpperArm) 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)) + let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) if let neck { neck.transform.rotation = neck.transform.rotation * neckRotation } - if let leftShoulder { - leftShoulder.transform.rotation = leftShoulder.transform.rotation * shoulderRotation + if let leftUpperArm { + leftUpperArm.transform.rotation = leftUpperArm.transform.rotation * upperArmRotation } - if let rightShoulder { - rightShoulder.transform.rotation = rightShoulder.transform.rotation * shoulderRotation + if let rightUpperArm { + rightUpperArm.transform.rotation = rightUpperArm.transform.rotation * upperArmRotation } vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) diff --git a/Example/WatchExample Watch App/ViewModel.swift b/Example/WatchExample Watch App/ViewModel.swift index 58577d7..51d5ee8 100644 --- a/Example/WatchExample Watch App/ViewModel.swift +++ b/Example/WatchExample Watch App/ViewModel.swift @@ -55,8 +55,8 @@ final class ViewModel: ObservableObject { let rotationOffset = model.initialRotation node.eulerAngles = SCNVector3(0, rotationOffset, 0) - 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) + node.humanoid.node(for: .leftUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) + node.humanoid.node(for: .rightUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / -180) node.runAction(.repeatForever(.sequence([ .wait(duration: 3.0), diff --git a/README.md b/README.md index b218adb..268ff98 100644 --- a/README.md +++ b/README.md @@ -149,10 +149,10 @@ vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) ```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)) +let upperArmRotation = 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 +vrmEntity.humanoid.node(for: .leftUpperArm)?.transform.rotation *= upperArmRotation +vrmEntity.humanoid.node(for: .rightUpperArm)?.transform.rotation *= upperArmRotation ``` ### Read the thumbnail image From efdd3944be151cd18fcd7c7e0bf8ac588c46b6a5 Mon Sep 17 00:00:00 2001 From: tatsuya ogawa Date: Wed, 18 Mar 2026 20:32:26 +0900 Subject: [PATCH 2/4] vrm1 revert to shoulder --- .../Example/RealityKitViewController.swift | 22 +++++++++++++------ Example/Example/ViewController.swift | 14 ++++++++++-- Example/MacExample/ContentView.swift | 22 +++++++++++++------ Example/VisionExample/ContentView.swift | 22 +++++++++++++------ .../WatchExample Watch App/ViewModel.swift | 15 +++++++++++-- README.md | 18 ++++++++++++--- 6 files changed, 85 insertions(+), 28 deletions(-) diff --git a/Example/Example/RealityKitViewController.swift b/Example/Example/RealityKitViewController.swift index f448e04..9d09091 100644 --- a/Example/Example/RealityKitViewController.swift +++ b/Example/Example/RealityKitViewController.swift @@ -100,19 +100,27 @@ final class RealityKitViewController: UIViewController, UIGestureRecognizerDeleg updateCameraTransform() let neck = vrmEntity.humanoid.node(for: .neck) - let leftUpperArm = vrmEntity.humanoid.node(for: .leftUpperArm) - let rightUpperArm = vrmEntity.humanoid.node(for: .rightUpperArm) + let leftArm: Entity? + let rightArm: Entity? + switch vrmEntity.vrm { + case .v1: + leftArm = vrmEntity.humanoid.node(for: .leftShoulder) + rightArm = vrmEntity.humanoid.node(for: .rightShoulder) + case .v0: + leftArm = vrmEntity.humanoid.node(for: .leftUpperArm) + rightArm = vrmEntity.humanoid.node(for: .rightUpperArm) + } let neckRotation = simd_quatf(angle: 20 * .pi / 180, axis: SIMD3(0, 0, 1)) - let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) + let armRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) if let neck { neck.transform.rotation = neck.transform.rotation * neckRotation } - if let leftUpperArm { - leftUpperArm.transform.rotation = leftUpperArm.transform.rotation * upperArmRotation + if let leftArm { + leftArm.transform.rotation = leftArm.transform.rotation * armRotation } - if let rightUpperArm { - rightUpperArm.transform.rotation = rightUpperArm.transform.rotation * upperArmRotation + if let rightArm { + rightArm.transform.rotation = rightArm.transform.rotation * armRotation } vrmEntity.setBlendShape(value: 1.0, for: .preset(currentExpression.preset)) diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 713918b..c3375cb 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -114,8 +114,18 @@ class ViewController: UIViewController { node.setBlendShape(value: 1.0, for: .preset(currentExpression.preset)) node.humanoid.node(for: .neck)?.eulerAngles = SCNVector3(0, 0, 20 * CGFloat.pi / 180) - node.humanoid.node(for: .leftUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) - node.humanoid.node(for: .rightUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) + let leftArm: SCNNode? + let rightArm: SCNNode? + switch node.vrm { + case .v1: + leftArm = node.humanoid.node(for: .leftShoulder) + rightArm = node.humanoid.node(for: .rightShoulder) + case .v0: + leftArm = node.humanoid.node(for: .leftUpperArm) + rightArm = node.humanoid.node(for: .rightUpperArm) + } + leftArm?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) + rightArm?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) node.runAction(SCNAction.repeatForever(SCNAction.sequence([ SCNAction.rotateBy(x: 0, y: -0.5, z: 0, duration: 0.5), diff --git a/Example/MacExample/ContentView.swift b/Example/MacExample/ContentView.swift index 2b8f2d1..32a2e7e 100644 --- a/Example/MacExample/ContentView.swift +++ b/Example/MacExample/ContentView.swift @@ -73,19 +73,27 @@ final class ContentViewModel { // Adjust pose let neck = vrmEntity.humanoid.node(for: .neck) - let leftUpperArm = vrmEntity.humanoid.node(for: .leftUpperArm) - let rightUpperArm = vrmEntity.humanoid.node(for: .rightUpperArm) + let leftArm: Entity? + let rightArm: Entity? + switch vrmEntity.vrm { + case .v1: + leftArm = vrmEntity.humanoid.node(for: .leftShoulder) + rightArm = vrmEntity.humanoid.node(for: .rightShoulder) + case .v0: + leftArm = vrmEntity.humanoid.node(for: .leftUpperArm) + rightArm = vrmEntity.humanoid.node(for: .rightUpperArm) + } let neckRotation = simd_quatf(angle: 20 * .pi / 180, axis: SIMD3(0, 0, 1)) - let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) + let armRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) if let neck { neck.transform.rotation = neck.transform.rotation * neckRotation } - if let leftUpperArm { - leftUpperArm.transform.rotation = leftUpperArm.transform.rotation * upperArmRotation + if let leftArm { + leftArm.transform.rotation = leftArm.transform.rotation * armRotation } - if let rightUpperArm { - rightUpperArm.transform.rotation = rightUpperArm.transform.rotation * upperArmRotation + if let rightArm { + rightArm.transform.rotation = rightArm.transform.rotation * armRotation } vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) diff --git a/Example/VisionExample/ContentView.swift b/Example/VisionExample/ContentView.swift index 25683a0..a6dcd1d 100644 --- a/Example/VisionExample/ContentView.swift +++ b/Example/VisionExample/ContentView.swift @@ -103,19 +103,27 @@ final class ImmersiveViewModel { // Adjust pose let neck = vrmEntity.humanoid.node(for: .neck) - let leftUpperArm = vrmEntity.humanoid.node(for: .leftUpperArm) - let rightUpperArm = vrmEntity.humanoid.node(for: .rightUpperArm) + let leftArm: Entity? + let rightArm: Entity? + switch vrmEntity.vrm { + case .v1: + leftArm = vrmEntity.humanoid.node(for: .leftShoulder) + rightArm = vrmEntity.humanoid.node(for: .rightShoulder) + case .v0: + leftArm = vrmEntity.humanoid.node(for: .leftUpperArm) + rightArm = vrmEntity.humanoid.node(for: .rightUpperArm) + } let neckRotation = simd_quatf(angle: 20 * .pi / 180, axis: SIMD3(0, 0, 1)) - let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) + let armRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) if let neck { neck.transform.rotation = neck.transform.rotation * neckRotation } - if let leftUpperArm { - leftUpperArm.transform.rotation = leftUpperArm.transform.rotation * upperArmRotation + if let leftArm { + leftArm.transform.rotation = leftArm.transform.rotation * armRotation } - if let rightUpperArm { - rightUpperArm.transform.rotation = rightUpperArm.transform.rotation * upperArmRotation + if let rightArm { + rightArm.transform.rotation = rightArm.transform.rotation * armRotation } vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) diff --git a/Example/WatchExample Watch App/ViewModel.swift b/Example/WatchExample Watch App/ViewModel.swift index 51d5ee8..5cc65ef 100644 --- a/Example/WatchExample Watch App/ViewModel.swift +++ b/Example/WatchExample Watch App/ViewModel.swift @@ -55,8 +55,19 @@ final class ViewModel: ObservableObject { let rotationOffset = model.initialRotation node.eulerAngles = SCNVector3(0, rotationOffset, 0) - node.humanoid.node(for: .leftUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) - node.humanoid.node(for: .rightUpperArm)?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / -180) + let leftArm: SCNNode? + let rightArm: SCNNode? + switch node.vrm { + case .v1: + leftArm = node.humanoid.node(for: .leftShoulder) + rightArm = node.humanoid.node(for: .rightShoulder) + case .v0: + leftArm = node.humanoid.node(for: .leftUpperArm) + rightArm = node.humanoid.node(for: .rightUpperArm) + } + + leftArm?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / 180) + rightArm?.eulerAngles = SCNVector3(0, 0, 40 * CGFloat.pi / -180) node.runAction(.repeatForever(.sequence([ .wait(duration: 3.0), diff --git a/README.md b/README.md index 268ff98..a2a47a4 100644 --- a/README.md +++ b/README.md @@ -149,10 +149,22 @@ vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) ```swift vrmEntity.setBlendShape(value: 1.0, for: .preset(.fun)) let neckRotation = simd_quatf(angle: 20 * .pi / 180, axis: SIMD3(0, 0, 1)) -let upperArmRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) +let armRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) +let leftArm: Entity? +let rightArm: Entity? + +switch vrmEntity.vrm { +case .v1: + leftArm = vrmEntity.humanoid.node(for: .leftShoulder) + rightArm = vrmEntity.humanoid.node(for: .rightShoulder) +case .v0: + leftArm = vrmEntity.humanoid.node(for: .leftUpperArm) + rightArm = vrmEntity.humanoid.node(for: .rightUpperArm) +} + vrmEntity.humanoid.node(for: .neck)?.transform.rotation *= neckRotation -vrmEntity.humanoid.node(for: .leftUpperArm)?.transform.rotation *= upperArmRotation -vrmEntity.humanoid.node(for: .rightUpperArm)?.transform.rotation *= upperArmRotation +leftArm?.transform.rotation *= armRotation +rightArm?.transform.rotation *= armRotation ``` ### Read the thumbnail image From 2c04d12b260a9c2ed0f88843a823c9e133f76c69 Mon Sep 17 00:00:00 2001 From: tatsuya ogawa Date: Wed, 18 Mar 2026 20:44:02 +0900 Subject: [PATCH 3/4] fix import error --- Example/MacExample/ContentView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Example/MacExample/ContentView.swift b/Example/MacExample/ContentView.swift index 32a2e7e..6e722f5 100644 --- a/Example/MacExample/ContentView.swift +++ b/Example/MacExample/ContentView.swift @@ -10,6 +10,7 @@ import SwiftUI import RealityKit internal import VRMRealityKit internal import Combine +internal import VRMKit struct ContentView: View { @State private var viewModel = ContentViewModel() From d60b5cb091aa7481fe57065d81ae4c0fcfb37cb3 Mon Sep 17 00:00:00 2001 From: tatsuya-ogawa Date: Wed, 18 Mar 2026 20:46:01 +0900 Subject: [PATCH 4/4] Update README.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a2a47a4..a277112 100644 --- a/README.md +++ b/README.md @@ -150,16 +150,12 @@ vrmEntity.setBlendShape(value: 1.0, for: .custom("><")) vrmEntity.setBlendShape(value: 1.0, for: .preset(.fun)) let neckRotation = simd_quatf(angle: 20 * .pi / 180, axis: SIMD3(0, 0, 1)) let armRotation = simd_quatf(angle: 40 * .pi / 180, axis: SIMD3(0, 0, 1)) -let leftArm: Entity? -let rightArm: Entity? - +let (leftArm, rightArm): (Entity?, Entity?) switch vrmEntity.vrm { case .v1: - leftArm = vrmEntity.humanoid.node(for: .leftShoulder) - rightArm = vrmEntity.humanoid.node(for: .rightShoulder) + (leftArm, rightArm) = (vrmEntity.humanoid.node(for: .leftShoulder), vrmEntity.humanoid.node(for: .rightShoulder)) case .v0: - leftArm = vrmEntity.humanoid.node(for: .leftUpperArm) - rightArm = vrmEntity.humanoid.node(for: .rightUpperArm) + (leftArm, rightArm) = (vrmEntity.humanoid.node(for: .leftUpperArm), vrmEntity.humanoid.node(for: .rightUpperArm)) } vrmEntity.humanoid.node(for: .neck)?.transform.rotation *= neckRotation