✨ Phase δ:render hook context への周期情報追加と API version 2 化 - #4
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.
概要
render hook の context に animation 単位の周期情報を追加し、公開 API version を 2 へ上げます。
外部 plugin が「表示上の最終 frame」を判定可能にすることが目的です。
従来は context に animation object のみが含まれており、plugin 側で内部構造を推測する必要がありました。
主な変更点
RenderAnimationContextに readonly のanimationLengthSeconds/renderSampleCount/loopMode/loopDelayFramesを追加RENDER_HOOKS_API.versionを 1 から 2 へ。必須 context の追加に伴う破壊的変更lengthが+Infinityの場合と、時刻が進まなくなった場合に throwrenderSampleCountは render loop が実際に生成する frame 数そのものです。animation.lengthから再計算すると丸め誤差で off-by-one が発生するため、同一配列から長さを取得します。loop 直後に
frames.lengthと突合する dev guard (= warn のみ) を配置しました。周期情報は
renderedobject と同一 source から構築します。animation.select()の同期 dispatch による context と datapack meta の不一致を防ぐためです。spring 固有のロジックは含めていません。
「最終 frame が
N-2かN-1か」という解釈は Minecraft runtime の挙動に依存するため、利用側の plugin に委ねます。動作確認
yarn test: 104 passed / 1 todoyarn lint: 変更前と同一 (問題数の増加なし)有限長の animation で 時刻列そのもの が変更前と一致することを test で固定しました。
frame 数だけの比較では「件数は同じだが時刻が変わる」回帰を検出できないためです。
設計判断
NaN/-Infinityは throw しない。 0 frame で処理される従来の挙動を維持します。ハングの原因となる+Infinityのみを制限対象としました。onBeginAnimationの dispatch 前に確定させる必要があります。副作用として、hook 内でanimation.lengthを書き換えても loop 回数は不変となりますが、これはrenderSampleCountの保証として正しい挙動です。注意
loopModeは文字列 ('once'/'hold'/'loop') です。datapack meta の
lp(score 値) とはエンコードが異なります。指す設定は同じですが、値の表現が異なる点に注意してください。