Skip to content

vrm1.0 support#40

Merged
tattn merged 28 commits intotattn:feature/vrm1.0from
tatsuya-ogawa:feature/vrm1.0
Feb 3, 2026
Merged

vrm1.0 support#40
tattn merged 28 commits intotattn:feature/vrm1.0from
tatsuya-ogawa:feature/vrm1.0

Conversation

@tatsuya-ogawa
Copy link
Contributor

@tatsuya-ogawa tatsuya-ogawa commented Jan 26, 2026

VRM 1.0 Support & Migration Logic

Description

This PR introduces initial support for VRM 1.0 models, including a migration layer to bridge VRM 1.0 data to the existing VRM 0.x based internal architecture. It also includes a sample VRM 1.0 model and updates the example apps to demonstrate loading.

Changes

VRMKit Core

  • VRM 1.0 Migration: Added VRMMigration.swift to map VRM 1.0 data (meta, expressions, materials) to the existing internal VRM structure.
  • Material Support: Implemented extensive mapping for VRM 1.0 MToon and PBR materials to Unity-compatible shader properties (handling textures, colors, rendering modes).
  • Node & Data Structures: Updated Node.swift, VRM.swift, and VRM1.swift to accommodate VRM 1.0 specific fields.

Example Apps

  • New Sample Model: Added VRM1_Constraint_Twist_Sample.vrm to resources and build phases.
  • UI Updates: Updated VisionExample, MacExample, and VRMExample to support loading the new VRM 1.0 model (likely via a toggle or updated loader logic).

Project Configuration

  • Updated project.pbxproj to include the new VRM 1.0 sample file.

Note

  • Constraint not supported

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tatsuya-ogawa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the library by introducing full support for VRM 1.0 models. It includes a sophisticated migration mechanism that translates the newer VRM 1.0 data into the library's established VRM 0.x internal structures, ensuring seamless integration with existing rendering and animation pipelines. The accompanying example applications have been updated to showcase this new capability, providing a clear demonstration of loading and interacting with both VRM 0.x and VRM 1.0 models.

Highlights

  • VRM 1.0 Support: Added comprehensive support for parsing and loading VRM 1.0 models, enabling the library to handle the latest specification.
  • Data Migration Layer: Implemented a robust migration layer that translates VRM 1.0 data structures (meta, humanoid, blend shapes, first-person, secondary animation, materials) into the existing VRM 0.x internal representation for compatibility.
  • Example Application Updates: Updated example applications across RealityKit, SceneKit, VisionOS, and WatchOS to demonstrate VRM 1.0 model loading, including a new sample model and a UI for switching between VRM 0.x and VRM 1.0 models.
  • Enhanced Material Handling: Improved material parsing to support the KHR_materials_unlit glTF extension and refined MToon material property mapping for accurate rendering.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for VRM 1.0 models by adding new model assets, updating project configurations, and implementing migration logic from VRM 1.0 to VRM 0.x structures. The example applications have been updated to allow switching between VRM 0.x and VRM 1.0 models, demonstrating the new functionality. The changes also include necessary adjustments to material handling in RealityKit to ensure consistent rendering of MToon and unlit materials.

radius: sphere.radius
)
} else if let capsule = collider.shape.capsule {
// Approximate capsule as sphere (head)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Approximating capsule colliders as spheres might lead to less accurate collision detection for spring bones. While this might be a pragmatic choice due to API limitations, it's important to be aware that the physics simulation might not be as precise as intended by the VRM 1.0 specification.

Comment on lines +32 to +36
let mirror = Mirror(reflecting: vrm1.humanBones)
for child in mirror.children {
guard let label = child.label,
let humanBone1 = child.value as? VRM1.Humanoid.HumanBones.HumanBone?,
let node = humanBone1?.node else { continue }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using Mirror for iterating over vrm1.humanBones can be less performant and more fragile than an explicit mapping, especially if the structure of HumanBones changes in future VRM 1.0 revisions. While it works for direct property name to bone name mapping, it's generally not considered a best practice for production code due to its dynamic nature and potential for runtime errors if property names don't match expectations.

@tatsuya-ogawa tatsuya-ogawa marked this pull request as ready for review February 1, 2026 07:51
Copy link
Owner

@tattn tattn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tatsuya-ogawa Thank you again for this very valuable pull request!
I’ve left some comments, so please take a look when you have a chance.

materialPropertyNameMap = materialProperties.reduce(into: [:]) { $0[$1.name] = $1 }

if extensions.keys.contains("VRMC_vrm") {
// VRM 1.0 Support
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the VRM 0.x specification is described in VRM.swift, and the VRM 1.x specification is described in VRM1.swift.
Since this library was originally created before VRM 1.0, it has kept this naming scheme.

As a future direction, I was considering renaming the current VRM.swift to VRM0.swift, then introducing a new VRM.swift to abstract away the differences between model versions.

Do you think implementing this approach would be difficult?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think that will be difficult.This PR preserves the existing interface as much as possible, which should make future PRs easier to migrate.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. After merging, I’ll make some minor I/F adjustments to move toward these changes. Thank you!

Copy link
Owner

@tattn tattn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tatsuya-ogawa
I noticed a few points of concern in the migration process, so I’d like to check with you.

@tattn
Copy link
Owner

tattn commented Feb 3, 2026

@codex please review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 775d164bab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 16 to 21
Picker("Model", selection: $appModel.selectedModelName) {
ForEach(AppModel.ModelName.allCases) { model in
Text(model.displayName).tag(model)
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix mismatched braces in new Picker

The new Picker block closes twice (} at lines 20–21), which prematurely ends the Picker and the VStack body. This causes a Swift compile error (Expected '}' in …) and prevents the Vision example from building at all once this change is applied. Removing the extra closing braces so the .pickerStyle modifier attaches to the Picker fixes the build.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VisionPro Example does not show model.I am cheking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even main branch does not show models.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version can show models.
8afb5f9

checking difference from main branch.

@tatsuya-ogawa
Copy link
Contributor Author

@tattn
This version(8b1e648) seems to introduce issues affecting the visual appearance of models in the visionOS example,.

@tattn
Copy link
Owner

tattn commented Feb 3, 2026

@tatsuya-ogawa Oh, Thank you for the notice!
I forgot to add the model to visionOS Example's Copy Bundle Resources.
I fixed it later.

@tattn
Copy link
Owner

tattn commented Feb 3, 2026

Thank you for adding the job to the workflow!

Copy link
Owner

@tattn tattn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I’d like to adjust the examples and refine the API with future use in mind before merging into the main branch, I plan to merge this into feature/vrm1.0 for now.

Thank you very much for your help with the review and other support — it was extremely helpful!

@tattn tattn changed the base branch from main to feature/vrm1.0 February 3, 2026 11:00
@tattn tattn merged commit f4e0f8c into tattn:feature/vrm1.0 Feb 3, 2026
5 checks passed
tattn added a commit that referenced this pull request Feb 3, 2026
* vrm1.0 support (#40)

* vrm1.0 support

* Update Example/VisionExample/VisionExampleApp.swift

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* displayName

* displayName

* Update Example/VisionExample/ContentView.swift

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* materialName

* SpringBone

* revert Sources/VRMKit/VRM/Node.swift

* revert Sources/VRMKit/VRM/VRM1.swift

* Revert "revert Sources/VRMKit/VRM/VRM1.swift"

This reverts commit b66fe1c.

* Revert "revert Sources/VRMKit/VRM/Node.swift"

This reverts commit 445e5f6.

* fix test

* fix BlendShape

* fix comment

* remove comments

* fix comment

* mac example

* add testcase

* remove unnecessary comment

* SwiftTesting

* revert VRM1Tests.swift

* Revert "revert VRM1Tests.swift"

This reverts commit 6abaf87.

* refactor testcase

* allowedUserName

* texture transform

* fix build error

* add example build pipeline

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* feat: VRM files to example project resources

* Flip the model direction for visionOS example

Co-authored-by: tatsuya-ogawa <tatsuya-ogawa@users.noreply.github.com>

* New interfaces

- Updated VRM.MaterialProperty to VRM0.MaterialProperty for consistency.
- Removed VRMFileProtocol as it is no longer needed.
- Migrated VRM1 structures to VRM0 equivalents in VRMMigration.swift.
- Adjusted VRMLoader to support loading VRM0 thumbnails.
- Modified Humanoid and SecondaryAnimation classes to use VRM0 types.
- Updated tests to validate VRM0 functionality and migration from VRM1.
- Removed deprecated VRM1SceneLoader and related methods.
- Added new tests for VRM0 to ensure proper functionality and migration.

* feat: Add UIUserInterfaceStyle key for dark mode support in Info.plist

* feat: Improve shader handling for MToon and Unlit variants in VRMEntityLoader #42 (comment)

---------

Co-authored-by: tatsuya-ogawa <tatsuya-ogawa@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants