Skip to content

Draft: VRMC_springBone_limit #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Conversation

0b5vr
Copy link
Contributor

@0b5vr 0b5vr commented Feb 27, 2025

This is the first draft of VRMC_springBone_limit.

Added the Japanese spec and the schema, English spec is just a placeholder.

Added the Japanese spec and the schema, English spec is just a placeholder
@0b5vr 0b5vr added the enhancement New feature or request label Feb 27, 2025
@0b5vr 0b5vr self-assigned this Feb 27, 2025
ousttrue
ousttrue previously approved these changes Feb 28, 2025
phi ranges from -PI to PI, theta ranges from -PI/2 to PI/2
@0b5vr 0b5vr force-pushed the springBone-limit branch 3 times, most recently from 658ceed to 2eacd64 Compare April 18, 2025 06:22
@0b5vr 0b5vr force-pushed the springBone-limit branch from 2eacd64 to 97fdf66 Compare April 18, 2025 06:23
0b5vr added a commit to pixiv/three-vrm that referenced this pull request Apr 18, 2025
The implementation of the cone limit and its helper

TODOs:

- implement hinge limit
- implement polar limit
- implement loader plugin support for the limits

See: vrm-c/vrm-specification#496
0b5vr added a commit to pixiv/three-vrm that referenced this pull request Apr 18, 2025
The implementation of the hinge limit and its helper

I believe the current `calculateLimit` implementation has the improvement window

TODOs:

- implement polar limit
- implement loader plugin support for the limits

See: vrm-c/vrm-specification#496
0b5vr added a commit to pixiv/three-vrm that referenced this pull request Apr 18, 2025
The implementation of the spherical limit and its helper

TODOs:

- implement loader plugin support for the limits

See: vrm-c/vrm-specification#496
0b5vr added a commit to pixiv/three-vrm that referenced this pull request Apr 18, 2025
set `useLimits` to `false` if you want to check the fallback behavior

See: vrm-c/vrm-specification#496
ousttrue
ousttrue previously approved these changes Apr 22, 2025
Copy link
Contributor

@ousttrue ousttrue left a comment

Choose a reason for hiding this comment

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

LGTM


以下に、本拡張で定義する各リミットの参考実装を示します。

以下の参考実装において `tailDir` は、制限するjointの向きです。 `tailDir` は正規化されているものとします。
Copy link
Contributor

Choose a reason for hiding this comment

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

tailDir が突然出てくる感じがします。
node.rotation もしくは node.localRotation から話が始まるべきと思います。
もしくは既存の springBone 計算の中間値を使っているなら
それが出てくる過程も書いておく方がよいと思います。
要するに、コピペしてから使うところまでが遠いです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

確かに。それでいうと後者で、SpringBoneの計算過程で利用している (nextTail - worldPosition).normalizedtailDir になると思います。
VRMC_springBone 仕様側の擬似コードにも (nextTail - worldPosition).normalized には登場するので、これを言及する形に書き換えますね。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

以下のコミットで書き換えてみましたが、いかがでしょうか?
9e98e83


```ts
// Y+方向からjointのheadからtailに向かうベクトルへの最小回転
let axisRotation = fromToQuaternion(vec3(0, 1, 0), boneAxis);
Copy link
Contributor

Choose a reason for hiding this comment

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

boneAxis の意味を類推する必要があって、
難解になっているような。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

フィードバックありがとうございます。 boneAxis については、 VRMC_springBone 側の擬似コードでも定義されている「そのJointが対象とする子Nodeの、ローカル空間におけるレスト状態の伸びる方向」ですが、改めてこちらの文書でも説明することとします。

Copy link
Contributor Author

@0b5vr 0b5vr Jul 16, 2025

Choose a reason for hiding this comment

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

04b0db9 で対応しました。


### ConeLimit

以下は、擬似コードによるコーンリミットの参考実装です。
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

tailDir の導出が済んでいれば、異なるシステムでもコピペと微修正で使えそうです。
tailDir の導出は作業中(後でやる)です。

tailDir = tailDir.normalized;

// tailDirのy要素をjointに設定されたangleの余弦と比較する
let cosAngle = cos(joint.angle);
Copy link
Contributor

Choose a reason for hiding this comment

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

joint => limitParam など limit の設定値であることが見た目に分かる名前の方がわかりやすいと思われます。後続も同様です。

Copy link
Contributor Author

@0b5vr 0b5vr Jul 16, 2025

Choose a reason for hiding this comment

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

確かに、これは limit.angle のほうがより適切ですね。修正します。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1a14366 で対応しました。

@0b5vr 0b5vr force-pushed the springBone-limit branch from 68feb73 to 1a14366 Compare July 16, 2025 10:17
@ousttrue
Copy link
Contributor

対応ありがとうございます。
読みやすくなりました 👍

@ousttrue
Copy link
Contributor

SpringBone 処理の全体の流れの中での、位置が欲しいです。

VRMC_springBone_limit は、VRMC_springBone の一連の処理

  • 慣性計算
  • コライダーとの衝突
  • 回転への反映
  • Center spaceの考慮

のうち 回転への反映 処理を拡張するものである、
という感じの説明。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

2 participants