✨ Phase γ:AJ export への汎用 render hook 追加と export バグ 3 件の修正 - #3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
外部 plugin が AJ の datapack export に自分の計算結果を載せられるよう、汎用の pose pipeline hook を追加する。AJ 側は registry と dispatch だけを提供し、物理等の固有ロジックは持たない。あわせて、作業中に見つけた export 経路のバグ 3 件を修正する。
hook が 1 つも登録されていないときの出力は従来と完全に同一であることを最優先の条件とし、hook 導入前の実装が出した値と突き合わせて確認している。
主な変更点
追加した hook API
window.AnimatedJava.renderHooksとして公開する (=register(id, hooks)/unregister(id)/version)。callback は
onBeginRendering/onBeginAnimation/onPose/onEndAnimation/onEndRenderingの 5 つ。begin と pose は登録順、end は逆順に呼ぶ。updatePreviewが keyframe pose を scene に確定させた直後updateMatrixWorldを自分で呼ぶonPoseは同じframeIndexで 1 frame につき複数回呼ばれる (= IK のための二度呼び / pre-post の side sample とその巻き戻し / null_object ごとの再評価)。回数は blueprint 構成で変わるため、hook 側は回数を数えずframeIndexの変化だけを見るRenderHookErrorで hook id と phase を付けて export エラーへ surface する修正した export バグ
getFrameの 1 tick 前 keyframe 参照time - 0.05を格子へ再スナップしておらず、0〜3 秒の 61 frame 中 20 frame でMapがヒットしない。pre-post interpolation の指定が出力から落ちていた0.1 + 0.05が0.15000000000000002になり、frame ループ側の時刻から引けない)hashAnimationspos/rot/scaleしか mix していなかった。compiler は matrix 全体を使う (= 純正経路は 16 要素をそのまま、TSB 経路は SVD 分解) ため、shear や right rotation だけが変わると 出力は変わったのに hash が一致し、on_load の reload-skip が誤判定する例外時の状態復旧
renderProjectAnimationsは bone interpolation フラグ / scene の 180 度回転 / 選択中 animation を変更するが、復元が保護されておらず、例外で抜けると壊れた状態が残っていた。次の 3 点を入れた。動作確認
bun run test= 94 passed / 1 todo (= 本 PR の新規 61 件)。bun install --frozen-lockfileは差分なし、tsc --noEmitの error 件数は変更前と同数、prettier も pass。検証の中心は
src/tests/animationRenderExport.test.ts。Blockbench 無しで production のrenderProjectAnimationsを実走させ、次を確認する。node_transformsと hash が変わり、生成される mcfunction が byte 単位で変わる。変化が「1 回分だけ」であることも見る (= 冪等でない hook を入れると落ちる)注意
この PR は export 出力を変える。いずれもバグ修正による正しい変化だが、既存 blueprint の datapack は再生成が必要になる。
animation_hashの式が変わるため、次回 export 時に 1 回だけ全 cell が reload される未対応
animator.keyframesは channel 連結の getter (=rotation/position/scaleが順に並ぶ) だが、正規化ループはこれを 1 本の時系列として扱っている。channel をまたいだ衝突の誤検出、3 つ以上が同じ格子点へ丸まる場合の重複、ずらした結果がanimation.lengthを超える取りこぼしが残る。正しい修正には channel 単位への作り替えと実機検証が要るため本 PR では扱わない。現状の挙動は「既知の未解決欠陥」としてテストで固定してある