Skip to content
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

ある種のVMDファイルを読み込むときにINDEX_SIZE_ERRが出る問題 #4

Open
legokichi opened this issue Sep 27, 2012 · 0 comments

Comments

@legokichi
Copy link

  • error log

Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1 MMD.Motion.js:121
MMD.Motion.Motion.getSelfShadowMotion MMD.Motion.js:121
MMD.Motion.Motion.parse MMD.Motion.js:44
MMD.Motion.Motion.load.xhr.onload MMD.Motion.js:26

  • VMDファイルの中にはSelfShadowの情報がないものがあります。
  • ソース

DWORD lightCount; // 照明キーフレーム数
struct LightFrame light[lightCount]; // 照明要素データ
// MMDv6.19以前で保存されたVMDはここまで

DWORD sshadowCount; // セルフ影キーフレーム数
struct SelfShadowFrame sShadow[sshadowCount]; // セルフ影要素データ

  • 現行のMMD.Motion#parseはSelfShadowを必ず読みにいくので、SelfShadowのないVMDを読むと、存在しない領域を読み込むこととなり、エラーが発生します。

parse: (buffer) ->
length = buffer.byteLength
view = new DataView(buffer, 0)
offset = 0
offset = @checkHeader(buffer, view, offset)
offset = @getModelName(buffer, view, offset)
offset = @getBoneMotion(buffer, view, offset)
offset = @getMorphMotion(buffer, view, offset)
offset = @getCameraMotion(buffer, view, offset)
offset = @getLightMotion(buffer, view, offset)
offset = @getSelfShadowMotion(buffer, view, offset)

  • これを以下のように変えることを提案します。

parse: (buffer) ->
length = buffer.byteLength
view = new DataView(buffer, 0)
offset = 0
offset = @checkHeader(buffer, view, offset)
offset = @getModelName(buffer, view, offset)
offset = @getBoneMotion(buffer, view, offset)
offset = @getMorphMotion(buffer, view, offset)
offset = @getCameraMotion(buffer, view, offset)
offset = @getLightMotion(buffer, view, offset)
offset = @getSelfShadowMotion(buffer, view, offset) unless offset >= length
offset

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

No branches or pull requests

1 participant